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

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

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

第1题:

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

第2题:

Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()

  • A、p0 = p1;
  • B、p1 = p2;
  • C、p2 = p4;
  • D、p2 = (ClassC)p1;
  • E、p1 = (ClassB)p3;
  • F、p2 = (ClassC)p4;

正确答案:A,E,F

第3题:

Click the Exhibit button. What is the result? ()

A.Value is: 8

B.Compilation fails.

C.Value is: 12

D.Value is: -12

E.The code runs with no output.

F.An exception is thrown at runtime.


参考答案:A

第4题:

public class ClassA {  public int getValue() {  int value=0;  boolean setting = true;  String title=”Hello”;  (value || (setting && title == “Hello”)) { return 1; }  (value == 1 & title.equals(”Hello”)) { return 2; }  }  } And:  ClassA a = new ClassA();  a.getValue();  What is the result?() 

  • A、 1
  • B、 2
  • C、 Compilation fails.
  • D、 The code runs with no output.
  • E、 An exception is thrown at runtime.

正确答案:C

第5题:

10. public class ClassA {  11. public void methodA() {  12. ClassB classB = new ClassB();  13. classB.getValue();  14. }  15. }  And:  20. class ClassB {  21. public ClassC classC;  22.  23. public String getValue() {  24. return classC.getValue();  25. }  26. }  And:  30. class ClassC {  31. public String value;  32.  33. public String getValue() {  34. value = “ClassB”;  35. return value;  36. }  37. }  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

第6题:

Click the Exhibit button. What is the output if the main() method is run?()

A.4

B.5

C.8

D.9

E.Compilation fails.

F.An exception is thrown at runtime.

G.It is impossible to determine for certain.


参考答案:D

第7题:

public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()

  • A、 Finally
  • B、 Compilation fails.
  • C、 The code runs with no output.
  • D、 An exception is thrown at runtime.

正确答案:A

第8题:

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

第9题:

interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()  

  • A、 Tested
  • B、 Compilation fails.
  • C、 The code runs with no output.
  • D、 An exception is thrown at runtime.

正确答案:B

第10题:

11. static classA {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B “); }  16. }  17. public static void main(String[] args) {  18.A a=new B();  19. a.process();  20.}  What is the result?() 

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

正确答案:F

更多相关问题