单项选择题

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? ()

A. Compilation fails because of an error in line 19.
B. An exception is thrown at runtime.
C. B
D. Compilation fails because of an error in line 18.
E. Compilation fails because of an error in line 15. 
F. The code runs with no output.


您可能感兴趣的试卷

你可能感兴趣的试题

1.单项选择题

Given:  
12. System.out.format("Pi is approximately %d.", Math.PI);  
What is the result?()

A. An exception is thrown at runtime.
B. Pi is approximately 3.
C. Pi is approximately 3.141593.
D. Compilation fails.

5.单项选择题

Given:

What is the result?()

A. An exception is thrown at runtime.
B. r, e, o,
C. Compilation fails.
D. r, t, t,

6.单项选择题

Click the Exhibit button.  
Given: ClassA a = new ClassA();  
a.methodA();  
What is the result?()

A. The code runs with no output.
B. Compilation fails.
C. An exception is thrown at runtime.
D. ClassC is displayed.

7.单项选择题

Given:

What is the result of calling search with a valid List implementation? ()

A. 0
B. The result is undefined.
C. a
D. 2
E. 1
F. c
G. b

8.单项选择题

Given the command line java Pass2 and:

What is the result? ()

A. doStuff x = 6 main x = 6
B. Compilation fails.
C. doStuff x = 6 main x = 7
D. An exception is thrown at runtime.
E. doStuff x = 7 main x = 6
F. doStuff x = 7 main x = 7

9.多项选择题

Given:

Which five methods, inserted independently at line 5, will compile?()

A. protected int blipvert(long x) { return 0; }
B. protected long blipvert(int x) { return 0; }
C. private int blipvert(long x) { return 0; }
D. private int blipvert(int x) { return 0; }
E. public int blipvert(int x) { return 0; }
F. protected long blipvert(long x) { return 0; }
G. protected long blipvert(int x, int y) { return 0; }

10.单项选择题

Click the Exhibit button. 
 What is the result?()

A. The code will deadlock.
B. The code may run with output "2 0 6 4".
C. The code may run with no output.
D. The code may run with output "0 6".
E. An exception is thrown at runtime.
F. The code may run with output "0 2 4 6".

最新试题

Given:What is the result?()

题型:单项选择题

Click the Exhibit button.  Given:Which two statements are true if a NullPointerException is thrown on line 3 of class C?()

题型:多项选择题

Given:What is the result? ()

题型:单项选择题

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? ()

题型:单项选择题

Given:What is the result?() 

题型:单项选择题

Given:  11. String test = "This is a test";  12. String[] tokens = test.split("\s");  13. System.out.println(tokens.length);  What is the result?()

题型:单项选择题

Click the Exhibit button.  Given this code from Class B:  25. A a1 = new A();  26. A a2 = new A();  27. A a3 = new A();  28. System.out.println(A.getInstanceCount());  What is the result?()

题型:单项选择题

Given:  11. // insert code here  12. private N min, max;  13. public N getMin() { return min; }  14. public N getMax() { return max; }  15. public void add(N added) {  16. if (min == null  added.doubleValue() < min.doubleValue()) 17. min = added;  18. if (max == null  added.doubleValue() > max.doubleValue()) 19. max = added;  20. }  21. }  Which two, inserted at line 11, will allow the code to compile?()

题型:多项选择题

Click the Exhibit button.  What is the output of the program shown in the exhibit? ()

题型:单项选择题

Given: What is the result?()

题型:单项选择题