运行以下程序会抛出哪种异常?()publicclassTest{public static void main(String[] args) Object o = null;System.out.println(o);}
ArithmeticException
B. ArrayIndexOutOfBoundsException
C. StringIndexOutOfBoundsException
D. no Exception
E. NullPointerException
查看答案
执行如下程序后b的值为? ()int x, b=0; for(x = 0; x <= 5; ++x){ if (x == 2) continue; ++b; }
A. 5
B. 4
C. 3
给定如下代码:3. class Alpha {4. static String s = " ";5. protected Alpha() { s += "alpha "; }6. }7. class SubAlpha extends Alpha {8. private SubAlpha() { s += "sub "; }9. }10. public class SubSubAlpha extends Alpha {11. private SubSubAlpha() { s += "subsub "; }12. public static void main(String[] args) {13. new SubSubAlpha();14. System.out.println(s);15. }16. }运行结果为?()
A. subsub
B. sub subsub
C. alpha subsub
D. alpha sub subsub
运行类C的输出结果为?()class A { public A() { System.out.println( "The default constructor of A is invoked"); }} class B extends A { public B() { System.out.println( "The default constructor of B is invoked"); }} public class C { public static void main(String[] args) { B b = new B(); }}
A. 无任何显示
B. "The default constructor of B is invoked"
C. "The default constructor of A is invoked""The default constructor of B is invoked"
D. "The default constructor of B is invoked""The default constructor of A is invoked"
下面是People和Child类的定义和构造方法,请选择输出结果class People {String name;public People() { System.out.print(1); }public People(String name) {System.out.print(2);this.name = name;}} class Child extends People {People father;public Child(String name) {System.out.print(3);this.name = name;father = new People(name + ":F");}public Child(){ System.out.print(4); }}
A. 32
B. 312
C. 13
D. 132