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 / souvik
The answer will be first option B since the object created is of B type and it is calling directly the process method in B class
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the differences between heap and stack memory in java? Explain
Can we override constructors in java?
How can an object be unreferenced?
What does += mean coding?
According to java operator precedence, which operator is considered to be with highest precedence?
Can you have two constructors in java?
What is the difference between call by reference and call by pointer?
What is the purpose of the return statement?
Is there any difference between synchronized methods and synchronized statements?
What is the symbol for line break?
Can a constructor be made final?
How many inner classes can a class have?
Are global variables initialized to zero?
What are the difference between composition and inheritance in java?
What is compiler and what its output.