OCJP(310-065)

单选题Given: What is the result?()ACompilation succeeds.BCompilation fails due to multiple errors.CCompilation fails due to an error only on line 20.DCompilation fails due to an error only on line 21.ECompilation fails due to an error only on line 22.

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

Compilation succeeds.

B

Compilation fails due to multiple errors.

C

Compilation fails due to an error only on line 20.

D

Compilation fails due to an error only on line 21.

E

Compilation fails due to an error only on line 22.

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

第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题:

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

第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题:

单选题
1. interface DoStuff2 {  2. float getRange(int low, int high); }  3.  4. interface DoMore {  5. float getAvg(int a, int b, int c); }  6.  7. abstract class DoAbstract implements DoStuff2, DoMore { }  8.  9. class DoStuff implements DoStuff2 {  10. public float getRange(int x, int y) { return 3.14f; } }  11.  12. interface DoAll extends DoMore {  13. float getAvg(int a, int b, int c, int d); }  What is the result?()
A

 The file will compile without error.

B

 Compilation fails. Only line 7 contains an error.

C

 Compilation fails. Only line 12 contains an error.

D

 Compilation fails. Only line 13 contains an error.

E

 Compilation fails. Only lines 7 and 12 contain errors.

F

 Compilation fails. Only lines 7 and 13 contain errors.

G

 Compilation fails. Lines 7, 12, and 13 contain errors.


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

第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题:

1. interface DoStuff2 {  2. float getRange(int low, int high); }  3.  4. interface DoMore {  5. float getAvg(int a, int b, int c); }  6.  7. abstract class DoAbstract implements DoStuff2, DoMore { }  8.  9. class DoStuff implements DoStuff2 {  10. public float getRange(int x, int y) { return 3.14f; } }  11.  12. interface DoAll extends DoMore {  13. float getAvg(int a, int b, int c, int d); }  What is the result?() 

  • A、 The file will compile without error.
  • B、 Compilation fails. Only line 7 contains an error.
  • C、 Compilation fails. Only line 12 contains an error.
  • D、 Compilation fails. Only line 13 contains an error.
  • E、 Compilation fails. Only lines 7 and 12 contain errors.
  • F、 Compilation fails. Only lines 7 and 13 contain errors.
  • G、 Compilation fails. Lines 7, 12, and 13 contain errors.

正确答案: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题:

1. package foo; 2.  3. import java.util.Vector; 4.  5. protected class MyVector Vector { 6. init i = 1; 7. public MyVector() { 8. i = 2; 9. } 10. } 11.  12. public class MyNewVector extends MyVector { 13. public MyNewVector() { 14. i = 4; 15. } 16. public static void main(String args[]) { 17. MyVector v = new MyNewVector(); 18. } 19. } 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

第10题:

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

test

B

null

C

An exception is thrown at runtime.

D

Compilation fails because of an error in line 1.

E

Compilation fails because of an error in line 4.

F

Compilation fails because of an error in line 5.


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

更多相关问题