The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 20.
Compilation fails because of an error in line 21.
Compilation fails because of an error in line 23.
Compilation fails because of an error in line 25.
第1题:
11. public static void main(String[] args) { 12. Integer i = uew Integer(1) + new Integer(2); 13. switch(i) { 14. case 3: System.out.println(”three”); break; 15. default: System.out.println(”other”); break; 16. } 17. } What is the result?()
第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?()
第3题:
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?()
第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? ()
第5题:
Compilation succeeds.
Compilation fails due to multiple errors.
Compilation fails due to an error only on line 20.
Compilation fails due to an error only on line 21.
Compilation fails due to an error only on line 22.
第6题:
B
B, followed by an Exception.
Compilation fails due to an error on line 9.
Compilation fails due to an error on line 14.
An Exception is thrown with no other output.
第7题:
Compilation succeeds.
Compilation fails because of an error at line 5.
Compilation fails because of an error at line 6.
Compilation fails because of an error at line 14.
Compilation fails because of an error at line 17.
第8题:
Compilation fails because of an error in line 13.
A ClassCastException is thrown at runtime.
1 2 3
Compilation fails because of an error in line 14.
Compilation fails because of an error in line 12.
第9题:
An Exception is thrown with no other output
followed by an Exception
Compilation fails due to an error on line 9
Compilation fails due to an error on line 14
第10题:
Compilation succeeds.
Compilation fails due to multiple errors.
Compilation fails due to an error only on line 20.
Compilation fails due to an error only on line 21.
Compilation fails due to an error only on line 22.
Compilation fails due to an error only on line 12.
第11题:
True
Not true
An exception is thrown at runtime.
Compilation fails because of an error at line 12.
Compilation fails because of an error at line 19.
第12题:
B
The code runs with no output.
Compilation fails because of an error in line 12.
Compilation fails because of an error in line 15.
Compilation fails because of an error in line 18.
第13题:
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? ()
第14题:
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?()
第15题:
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?()
第16题:
B
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 15.
Compilation fails because of an error in line 18.
Compilation fails because of an error in line 19.
第17题:
test
null
An exception is thrown at runtime.
Compilation fails because of an error in line 1.
Compilation fails because of an error in line 4.
Compilation fails because of an error in line 5.
第18题:
42
An exception is thrown at runtime.
Compilation fails because of an error on line 12.
Compilation fails because of an error on line 16.
Compilation fails because of an error on line 17.
第19题:
Compilation fails because of an error in line 19.
An exception is thrown at runtime.
B
Compilation fails because of an error in line 18.
Compilation fails because of an error in line 15.
The code runs with no output.
第20题:
X, followed by an Exception.
No output, and an Exception is thrown.
Compilation fails due to an error on line 14.
Compilation fails due to an error on line 16.
Compilation fails due to an error on line 17.
第21题:
B
The code runs with no output.
Compilation fails because of an error in line 12.
Compilation fails because of an error in line 15.
Compilation fails because of an error in line 18.
第22题:
test
null
An exception is thrown at runtime.
Compilation fails because of an error in line 1.
Compilation fails because of an error in line 4.
Compilation fails because of an error in line 5.
第23题:
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 20.
Compilation fails because of an error in line 21.
Compilation fails because of an error in line 23.
Compilation fails because of an error in line 25.