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?
1 B
2 The code runs with no output.
3 Compilation fails because of an error in
line 12.
4 Compilation fails because of an error in
line 15.
Answer Posted / manikandan [ gtec,vellore ]
Answer is 1)B because we directly calling a process method
in class B
| Is This Answer Correct ? | 5 Yes | 2 No |
Post New Answer View All Answers
What is the importance of finally block in exception handling?
How do you implement singleton class?
What is the difference between final, finally and finalize() in java?
Can we start a thread twice in java?
Does a function need a return?
What interface is extended by awt event listeners?
How can a gui component handle its own events?
What is starvation?
Can a source file contain more than one class declaration?
What are examples of modifiers?
What is prefix of a string?
What is meant by singleton class?
Why packages are used?
Is constructor inherited?
What is the use of predicate in java 8?