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
Given a singly linked list, determine whether it contains a loop or not without using temporary space?
Explain the usage of this with constructors?
How to do a true java ping from windows?
What is the use of generics? When was it added to the Java development Kit?
What is the difference between length and size in java?
What is the transient keyword?
What is the difference between an argument and a parameter?
What are the different types of data structures in java?
What is the difference between state-based unit testing and interaction-based unit testing?
What is factor r?
Explain about instanceof operator in java?
What is ascii format?
What is a package in java? List down various advantages of packages.
What is an iterator java?
Explain the difference between collection api and stream api in java8?