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
Is .net better than java?
What is encapsulation in java?
What is a buffer in java?
What is the purpose of the enableevents() method?
Is array size fixed in java?
What is the difference between hashmap and hashtable in java?
Why do we use predicate in java?
How do you use spaces in java?
When a lot of changes are required in data, which one should be a preference to be used? String or stringbuffer?
What two classes are used to read data only?
How do you format in java?
Can I use % with real numbers?
What is the difference between checked exception and unchecked exception?
What restrictions are placed on method overloading in java programming?
Can a constructor be protected?