更多“下面程序运行的结果是() class pClass { public string Name; public string Id; public void fun() { Console.WriteL…”相关的问题
第1题
下面程序的运行结果是( ) public class Demo { public static void main(String[] args) { try { System.out.println(10 / 0); } catch (RuntimeException e) { System.out.println("RuntimeException"); } catch (ArithmeticException e) { System.out.println("ArithmeticException"); } } }
A、编译失败
B、编译通过,没有结果输出
C、输出:RuntimeException
D、输出:ArithmeticException
点击查看答案
第2题
以下程序的调试结果为( )。 public class Outer{ public String name = "Outer"; public static void main(String argv[]){ Inner i = new Inner(); i.showName(); } private class Inner{ String name = new String("Inner"); void showName(){ System.out.println(name); } } }
A、输出结果 Outer
B、输出结果 Inner
C、编译错误,因 Inner 类定义为私有访问
D、在创建 Inner 类实例的行出现编译错误
点击查看答案
第3题
给定以下代码,程序的运行结果是 ()public class Test { public static void main(String[] args) { String result = reverse("happy"); System.out.println(result); } public static String reverse(String str) { StringBuilder result = new StringBuilder(""); char[] chArra = str.toCharArray(); for (int i = chArra.length - 1; i >= 0; i--) { char ch = chArra[i]; result.append(ch); } return result.toString(); } }
点击查看答案
第4题
以下程序的运行结果是:( ) public class Increment{ public static void main(String args[]) { int a; a = 6; System.out.print(a); System.out.print(a++); System.out.print(a); } }
点击查看答案
第5题
下面程序片段的运行结果是?( ) public class Test { public static void main(String[] args){ String[] subs = "25.5\n\ts18.66segmentation19".split("\\D+"); double result = 0.0; for (int i=0; i<subs.length; i++) result +="Double.parseDouble(subs[i]);" system.out.println(result); }> A、133.0
点击查看答案
第6题
1. 下列程序运行的输出结果是________。 public class Test { public static void main(String[] args) { for(int i=1;i<=10;i++) { continue; system.out.print(i+" "); }> A、1 2 3 4
B、1 2 3 4 5 6 7 8 9 10
C、6 7 8 9
D、6 7 8 9 10
点击查看答案
第7题
下面程序运行的结果是: public class test { private ArrayList Names = new ArrayList(); public test(string[] names) { foreach (string name in names) this.Names.Add(name); } public string this[int index] { get { return Names[2*index+1].ToString(); } } static void Main() { String[] names = new string[] { "A", "B", "C", "D" }; test t = new test(names); Console.WriteLine(t[1]); } }
点击查看答案
第8题
【简答题】预测程序运行结果 class Student{ private String name; public static String classNo; public Student(){} public Student(String name, String classNo){ this.name=name; this.classNO=classNo;} public static void show(){ System.out.println(“name=”+name+”classNo=”+classNo);}} public class StudentDemo{ public static void main(String []args){ Student s1=new Student(“张”,”计1”); Student s2=new Student(“李”,”计2”); s1.show();
点击查看答案
第9题
public class MyClass1 { public static void main(String argv[]){ } /*Modifier at XX */ class MyInner {} } 在XX处,使用哪个修饰符合法?
A、public
B、private
C、static
D、friend
点击查看答案
第10题
请阅读下面的程序 public class Test { public static void main(String[] args) { for(int x =0;x<5;x++) { if(x%2="=0)" break; system.out.print(x+” “); } 下列选项中,哪一个是程序的运行结果> A、1 2 3 4 5
点击查看答案