OCJP(310-065)

单选题Given: What is the result?()ABBThe code runs with no output.CCompilation fails because of an error in line 12.DCompilation fails because of an error in line 15.ECompilation fails because of an error in line 18.

题目
单选题
Given: What is the result?()
A

B

B

The code runs with no output.

C

Compilation fails because of an error in line 12.

D

Compilation fails because of an error in line 15.

E

Compilation fails because of an error in line 18.

参考答案和解析
正确答案: A
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

第2题:

11. static class A {  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. new B().process();  19. }  What is the result?() 

  • A、 B
  • B、 The code runs with no output.
  • C、 Compilation fails because of an error in line 12.
  • D、 Compilation fails because of an error in line 15.
  • E、 Compilation fails because of an error in line 18.

正确答案:A

第3题:

public static void main(String[]args){12.Object obj=new int[]{1,2,3};13.int[] someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+"")15.}What is the result?()

A.123

B.Compilation fails because of an error in line 12.

C.Compilation fails because of an error in line 13.

D.Compilation fails because of an error in line 14.

E.A ClassCastException is thrown at runtime.


参考答案:A

第4题:

Given:   11. static class A {   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、 Compilation fails because of an error in line 19.
  • B、 An exception is thrown at runtime.
  • C、 B
  • D、 Compilation fails because of an error in line 18.
  • E、 Compilation fails because of an error in line 15. 
  • F、 The code runs with no output.

正确答案:A

第5题:

11.public static void main(String[]args){ 12.Object obj=new int[]{1,2,3}; 13.int[] someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} What is the result?()

  • A、123
  • B、Compilation fails because of an error in line 12.
  • C、Compilation fails because of an error in line 13.
  • D、Compilation fails because of an error in line 14.
  • E、A ClassCastException is thrown at runtime.

正确答案:A

第6题:

11. public static void main(String[] args) {  12. Object obj = new Object() {  13. public int hashCode() {  14. returns 42; 15. }  16. };  17. System.out.println(obj.hashCode());  18. }    What is the result? () 

  • A、 42
  • B、 An exception is thrown at runtime.
  • C、 Compilation fails because of an error on line 12.
  • D、 Compilation fails because of an error on line 16.
  • E、 Compilation fails because of an error on line 17.

正确答案:A

第7题:

package foo;  import java.util.Vector; private class MyVector extends Vector {  int i = 1;  public MyVector() {  i = 2; } }  public class MyNewVector extends MyVector {  public MyNewVector() {  i = 4;  }  public static void main(String args[]) {  MyVector v = new MyNewVector();  }  }  What is the result?()

  • A、 Compilation succeeds.
  • B、 Compilation fails because of an error at line 5.
  • C、 Compilation fails because of an error at line 6.
  • D、 Compilation fails because of an error at line 14.
  • E、 Compilation fails because of an error at line 17.

正确答案:B

第8题:

Given:What is the result when method testIfA is invoked?()

A.True

B.Not true

C.An exception is thrown at runtime.

D.Compilation fails because of an error at line 12.

E.Compilation fails because of an error at line 19.


参考答案:A

第9题:

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

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


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

更多相关问题