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
Explain wrapper classes in java?
Difference between notify() method and notifyall() method in java?
How do you escape a string?
What is the core java?
Can variables be used in java without initialization?
What is compareto () in java?
What is the difference between the size and capacity of a vector?
What do you understand by the term polymorphism?
What about interthread communication and how it takes place in java?
Why is boolean important?
What is square root in java?
What is a boolean expression in java?
What are checked exceptions?
Does every java program need a main?
Can a class be private or protected in java?