Compilation fails because of an error in line 7.
Compilation fails because of an error in line 9.
If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
第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?()
第2题:
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?()
第3题:
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.
第4题:
1. interface A { public void aMethod(); } 2. interface B { public void bMethod(); } 3. interface C extends A,B { public void cMethod(); } 4. class D implements B { 5. public void bMethod() { } 6. } 7. class E extends D implements C { 8. public void aMethod() { } 9. public void bMethod() { } 10. public void cMethod() { } 11. } What is the result?()
第5题:
1. interface TestA { String toString(); } 2. public class Test { 3. public static void main(String[] args) { 4. System.out.println(new TestA() { 5. public String toString() { return “test”; } 6. } 7. } 8. } What is the result?()
第6题:
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?()
第7题:
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?()
第8题:
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.
第9题:
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? ()
第10题:
Compilation fails because of an error in line 3.
Compilation fails because of an error in line 7.
Compilation fails because of an error in line 9.
If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.
If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.