The code runs with no output.
Compilation fails.
An exception is thrown at runtime.
ClassC is displayed.
第1题:
A.Line 26 prints "a" to System.out.
B.Line 26 prints "b" to System.out.
C.An exception is thrown at line 26 at runtime.
D.Compilation of class A will fail due to an error in line 6.
第2题:
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?()
第3题:
A.Value is: 8
B.Compilation fails.
C.Value is: 12
D.Value is: -12
E.The code runs with no output.
F.An exception is thrown at runtime.
第4题:
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?()
第5题:
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?()
第6题:
A.4
B.5
C.8
D.9
E.Compilation fails.
F.An exception is thrown at runtime.
G.It is impossible to determine for certain.
第7题:
public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } What is the result?()
第8题:
A.Compilation fails.
B.ClassC is displayed.
C.The code runs with no output.
D.An exception is thrown at runtime.
第9题:
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?()
第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?()