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 difference between null and void?
How to call one constructor from the other constructor ?
How do you replace all in word?
What are byte codes?
What are kinds of processors?
Explain the significance of class loaders in bootstrap?
Is java code slower than native code?
Is math an abstract class in java?
What is the main use of generics in java?
Can java object be locked down for exclusive use by a given thread?
Which is bigger double or float?
What restrictions are placed on method overriding in java programming?
What is meant by polymorphism?
If a method is declared as protected, where may the method be accessed?
Can we extend singleton class?