1Z0-853

单选题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.

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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.


参考答案:B, E

第2题:

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

第3题:

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.


参考答案:D

第4题:

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

第5题:

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

第6题:

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”.

正确答案:E

第7题:

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

第8题:

Click the Exhibit button.Given: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

第9题:

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

第10题:

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

更多相关问题