题目内容

给定如下代码: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

程序运行后times的值是()?public class Test { public static void main(String[] args) { Count myCount = new Count(); int times = 0; for (int i=0; i<100; i++) increment(myCount, times); System.out.println("times = "+ times); } public static void increment(Count c, int times) { c.count++; times++; }}class Count { int count; Count(int c) { count = c; } Count() { count = 1; }}A:101B:100C:1D:03.给定如下程序:(B)3. public class Navel {4. private int size = 7;5. private static int length = 3;6. public static void main(String[] args) {7. new Navel().go();8. }9. void go() {10. int size = 5;11. System.out.println(new Gazer().adder());12. }13. class Gazer {14. int adder() { return size * length; }15. }16. }运行结果为?

A. 15
B. 21
C. 抛出异常
D. 由于多个error编译出错

Java语言与C++语言相比,最突出的特点()

A. 面向对象
B. 有类库
C. 高性能
D. 跨平台

答案查题题库