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:
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 15.

B.
An exception is thrown at runtime.

C.
The code runs with no output.

D.
Compilation fails because of an error in line 19.

E.
Compilation fails because of an error in line 18.

F.
B



Leave a Reply 0

Your email address will not be published. Required fields are marked *