单选题Click the Exhibit button.   Given this code from Class B:   25. A a1 = new A();   26. A a2 = new A();   27. A a3 = new A();   28. System.out.println(A.getInstanceCount());   What is the result?()ACompilation of class A fails.BLine 28 prints the value 3

题目
单选题
Click the Exhibit button.   Given this code from Class B:   25. A a1 = new A();   26. A a2 = new A();   27. A a3 = new A();   28. System.out.println(A.getInstanceCount());   What is the result?()
A

 Compilation of class A fails.

B

 Line 28 prints the value 3 to System.out.

C

 Line 28 prints the value 1 to System.out.

D

 Compilation fails because of an error on line 28.

E

 A runtime error occurs when line 25 executes.


相似考题
参考答案和解析
正确答案: A
解析: 暂无解析
更多“单选题Click the Exhibit button.   Given this code from Class B:   25. A a1 = new A();   26. A a2 = new A();   27. A a3 = new A();   28. System.out.println(A.getInstanceCount());   What is the result?()A  Compilation of class A fails.B  Line 28 prints the v”相关问题
  • 第1题:

    public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() 

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 The code executes normally and prints “bar”.
    • D、 The code executes normally, but nothing prints.

    正确答案:C

  • 第2题:

    class A {  public A() {  System.out.println(“hello from a”);  }  }  class B extends A {  public B () {  System.out.println(“hello from b”);  super();  }  }  public class Test {  public static void main(String args[]) {  A a = new B();  }  }   What is the result when main is executed?()  

    • A、 Compilation fails.
    • B、 hello from a
    • C、 hello from b
    • D、 hello from b hello from a
    • E、 hello from a hello from b

    正确答案:A

  • 第3题:

    1. public class A {  2. public void method1() {  3. B b=new B();  4. b.method2();  5. // more code here  6. }  7. }  1. public class B {  2. public void method2() {  3.C c=new C();  4. c.method3();  5. // more code here  6. }  7. }  1. public class C {  2. public void method3() {  3. // more code here  4. }  5. }  Given:  25. try {  26. A a=new A();  27. a.method1();  28. } catch (Exception e) {  29. System.out.print(”an error occurred”);  30. }  Which two are true if a NullPointerException is thrown on line 3 of class C?()

    • A、 The application will crash.
    • B、 The code on line 29 will be executed.
    • C、 The code on line 5 of class A will execute.
    • D、 The code on line 5 of class B will execute.
    • E、 The exception will be propagated back to line 27.

    正确答案:B,E

  • 第4题:

    1. public class A {  2.  3. private int counter = 0;  4.  5. public static int getInstanceCount() {  6. return counter;  7. }  8.  9. public A() {  10. counter++;  11. }  12.  13. }  Given this code from Class B:  25.A a1 =new A();  26. A a2 =new A();  27. A a3 =new A();  28. System.out.printIn(A.getInstanceCount() ); What is the result?() 

    • A、 Compilation of class A fails.
    • B、 Line 28 prints the value 3 to System.out.
    • C、 Line 28 prints the value 1 to System.out.
    • D、 A runtime error occurs when line 25 executes.
    • E、 Compilation fails because of an error on line 28.

    正确答案:A

  • 第5题:

    单选题
    public class Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     The code executes and prints “running”.

    D

     The code executes and prints “runningrunning”.

    E

     The code executes and prints “runningrunningrunning”.


    正确答案: D
    解析: 暂无解析

  • 第6题:

    单选题
    Click the Exhibit button. Given: ClassA a = new ClassA( ); a.methodA( ); What is the result? ()
    A

    Compilation fails.

    B

    ClassC is displayed.

    C

    The code runs with no output.

    D

    An exception is thrown at runtime.


    正确答案: B
    解析: 暂无解析

  • 第7题:

    单选题
    11. class Cup { }  12. class PoisonCup extends Cup { }  21. public void takeCup(Cup c) {  22. if(c instanceof PoisonCup) {  23. System.out.println(”Inconceivable!”);  24. } else if(c instanceof Cup) {  25. System.out.println(”Dizzying intellect!”);  26. } else {  27. System.exit(0);  28. }  29. }  And the execution of the statements:  Cup cup = new PoisonCup(); takeCup(cup);  What is the output?()
    A

     Inconceivable!

    B

     Dizzying intellect!

    C

     The code runs with no output.

    D

     An exception is thrown at runtime.

    E

     Compilation fails because of an error in line 22.


    正确答案: C
    解析: 暂无解析

  • 第8题:

    单选题
    Click the Exhibit button.   Given this code from Class B:   25. A a1 = new A();   26. A a2 = new A();   27. A a3 = new A();   28. System.out.println(A.getInstanceCount());   What is the result?()
    A

     Compilation of class A fails.

    B

     Line 28 prints the value 3 to System.out.

    C

     Line 28 prints the value 1 to System.out.

    D

     Compilation fails because of an error on line 28.

    E

     A runtime error occurs when line 25 executes.


    正确答案: E
    解析: 暂无解析

  • 第9题:

    单选题
    public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     The code executes normally and prints “bar”.

    D

     The code executes normally, but nothing prints.


    正确答案: A
    解析: 暂无解析

  • 第10题:

    单选题
    What is the result?()
    A

    Compilation of class A fails.

    B

    Line 28 prints the value 3 to System.out.

    C

    Line 28 prints the value 1 to System.out.

    D

    A runtime error occurs when line 25 executes.

    E

    Compilation fails because of an error on line 28.


    正确答案: E
    解析: 暂无解析

  • 第11题:

    多选题
    Click the Exhibit button. Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C? ()
    A

    The application will crash.

    B

    The code on line 29 will be executed.

    C

    The code on line 5 of class A will execute.

    D

    The code on line 5 of class B will execute.

    E

    The exception will be propagated back to line 27.


    正确答案: A,B
    解析: 暂无解析

  • 第12题:

    单选题
    1. public class A {  2.  3. private int counter = 0;  4.  5. public static int getInstanceCount() {  6. return counter;  7. }  8.  9. public A() {  10. counter++;  11. }  12.  13. }  Given this code from Class B:  25.A a1 =new A();  26. A a2 =new A();  27. A a3 =new A();  28. System.out.printIn(A.getInstanceCount() ); What is the result?()
    A

     Compilation of class A fails.

    B

     Line 28 prints the value 3 to System.out.

    C

     Line 28 prints the value 1 to System.out.

    D

     A runtime error occurs when line 25 executes.

    E

     Compilation fails because of an error on line 28.


    正确答案: E
    解析: 暂无解析

  • 第13题:

    10. interface A { void x(); }  11. class B implements A { public void x() { } public voidy() { } }  12. class C extends B { public void x() {} }  And:  20. java.util.List list = new java.util.ArrayList();  21. list.add(new B());  22. list.add(new C());  23. for (A a:list) {  24. a.x();  25. a.y();;  26. }  What is the result?() 

    • A、 The code runs with no output.
    • B、 An exception is thrown at runtime.
    • C、 Compilation fails because of an error in line 20.
    • D、 Compilation fails because of an error in line 21.
    • E、 Compilation fails because of an error in line 23.
    • F、 Compilation fails because of an error in line 25.

    正确答案:F

  • 第14题:

    23. Object [] myObjects = {  24. new integer(12),  25. new String(”foo”),  26. new integer(5),  27. new Boolean(true)  28. };  29. Arrays.sort(myObjects);  30. for( int i=0; i31. System.out.print(myObjects[i].toString());  32. System.out.print(” “);  33. }  What is the result?() 

    • A、 Compilation fails due to an error in line 23.
    • B、 Compilation fails due to an error in line 29.
    • C、 A ClassCastException occurs in line 29.
    • D、 A ClassCastException occurs in line 31.
    • E、 The value of all four objects prints in natural order.

    正确答案:C

  • 第15题:

    11. class Cup { }  12. class PoisonCup extends Cup { }  21. public void takeCup(Cup c) {  22. if(c instanceof PoisonCup) {  23. System.out.println(”Inconceivable!”);  24. } else if(c instanceof Cup) {  25. System.out.println(”Dizzying intellect!”);  26. } else {  27. System.exit(0);  28. }  29. }  And the execution of the statements:  Cup cup = new PoisonCup(); takeCup(cup);  What is the output?() 

    • A、 Inconceivable!
    • B、 Dizzying intellect!
    • C、 The code runs with no output.
    • D、 An exception is thrown at runtime.
    • E、 Compilation fails because of an error in line 22.

    正确答案:A

  • 第16题:

    1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?() 

    • A、 Line 26 prints “a” to System.out.
    • B、 Line 26 prints „b” to System.out.
    • C、 An exception is thrown at line 26 at runtime.
    • D、 Compilation of class A will fail due to an error in line 6.

    正确答案:A

  • 第17题:

    单选题
    1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?()
    A

     Line 26 prints “a” to System.out.

    B

     Line 26 prints „b” to System.out.

    C

     An exception is thrown at line 26 at runtime.

    D

     Compilation of class A will fail due to an error in line 6.


    正确答案: C
    解析: 暂无解析

  • 第18题:

    单选题
    Click the Exhibit button. Given this code from Class B: 25.A a1 = new A(); 26.A a2 = new A(); 27.A a3 = new A(); 28.System.out.println(A.getInstanceCount()); What is the result?()
    A

    Compilation of class A fails.

    B

    Line 28 prints the value 3 to System.out.

    C

    Line 28 prints the value 1 to System.out.

    D

    A runtime error occurs when line 25 executes.

    E

    Compilation fails because of an error on line 28.


    正确答案: D
    解析: 暂无解析

  • 第19题:

    单选题
    Click the Exhibit button.   Given: ClassA a = new ClassA();   a.methodA();   What is the result?()
    A

     The code runs with no output.

    B

     Compilation fails.

    C

     An exception is thrown at runtime.

    D

     ClassC is displayed.


    正确答案: C
    解析: 暂无解析

  • 第20题:

    单选题
    Click the Exhibit button. What is the result?()
    A

    Line 26 prints "a" to System.out.

    B

    Line 26 prints "b" to System.out.

    C

    An exception is thrown at line 26 at runtime.

    D

    Compilation of class A will fail due to an error in line 6.


    正确答案: C
    解析: 暂无解析

  • 第21题:

    单选题
    Click the Exhibit button. What is the result?()
    A

    Compilation of class A fails.

    B

    Line 28 prints the value 3 to System.out.

    C

    Line 28 prints the value 1 to System.out.

    D

    A runtime error occurs when line 25 executes.

    E

    Compilation fails because of an error on line 28.


    正确答案: D
    解析: 暂无解析

  • 第22题:

    单选题
    class A {  public A() {  System.out.println(“hello from a”);  }  }  class B extends A {  public B () {  System.out.println(“hello from b”);  super();  }  }  public class Test {  public static void main(String args[]) {  A a = new B();  }  }   What is the result when main is executed?()
    A

     Compilation fails.

    B

     hello from a

    C

     hello from b

    D

     hello from b hello from a

    E

     hello from a hello from b


    正确答案: D
    解析: Call to super must be first statement in constructor. 

  • 第23题:

    单选题
    23. Object [] myObjects = {  24. new integer(12),  25. new String(”foo”),  26. new integer(5),  27. new Boolean(true)  28. };  29. Arrays.sort(myObjects);  30. for( int i=0; i31. System.out.print(myObjects[i].toString());  32. System.out.print(” “);  33. }  What is the result?()
    A

     Compilation fails due to an error in line 23.

    B

     Compilation fails due to an error in line 29.

    C

     A ClassCastException occurs in line 29.

    D

     A ClassCastException occurs in line 31.

    E

     The value of all four objects prints in natural order.


    正确答案: D
    解析: 暂无解析

  • 第24题:

    单选题
    10. interface A { void x(); }  11. class B implements A { public void x() { } public voidy() { } }  12. class C extends B { public void x() {} }  And:  20. java.util.List list = new java.util.ArrayList();  21. list.add(new B());  22. list.add(new C());  23. for (A a:list) {  24. a.x();  25. a.y();;  26. }  What is the result?()
    A

     The code runs with no output.

    B

     An exception is thrown at runtime.

    C

     Compilation fails because of an error in line 20.

    D

     Compilation fails because of an error in line 21.

    E

     Compilation fails because of an error in line 23.

    F

     Compilation fails because of an error in line 25.


    正确答案: F
    解析: 暂无解析