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
Why a dead thread occurs?
Why is a singleton bad?
Write a java program to check if a number is prime or not?
Is break statement can be used as labels in java?
How to stop a thread in java? Explain about sleep () method in a thread?
What is the role of garbage collector in java?
What is an example of a conditional statement?
What is the purpose of extern variable?
What are advantages and disadvantages of OOPs?
What is the gregoriancalendar class in java programming?
What is size_t?
What is annotation in java?
How to create a thread in java?
What is java thread dump, how can we get java thread dump of a program?
Why wait and notify methods are declared in object class?