The code runs with no output.
Compilation fails.
An exception is thrown at runtime.
ClassC is displayed.
第1题:
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?()
第2题:
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?()
第3题:
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?()
第4题:
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.
第5题:
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.
第6题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第7题:
Line 26 prints "a" to System.out.
Line 26 prints "b" to System.out.
An exception is thrown at line 26 at runtime.
Compilation of class A will fail due to an error in line 6.
第8题:
Finally
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第9题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
第10题:
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.
第11题:
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.
第12题:
Hello
Hello World
Compilation fails.
Hello World 5
The code runs with no output.
An exception is thrown at runtime.
第13题:
public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } What is the result?()
第14题:
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?()
第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题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints "sleep".
The code executes normally, but nothing is printed.
第17题:
The code will deadlock.
The code may run with output "2 0 6 4".
The code may run with no output.
The code may run with output "0 6".
An exception is thrown at runtime.
The code may run with output "0 2 4 6".
第18题:
Compilation fails.
An exception is thrown at runtime.
The code executes and prints "running".
The code executes and prints "runningrunning".
The code executes and prints "runningrunningrunning".
第19题:
p0 = p1;
p1 = p2;
p2 = p4;
p2 = (ClassC)p1;
p1 = (ClassB)p3;
p2 = (ClassC)p4;
第20题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第21题:
test end
Compilation fails.
test runtime end
test exception end
A Throwable is thrown by main at runtime.
第22题:
1
2
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第23题:
1
2
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.