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


Please Help Members By Posting Answers For Below Questions

Why a dead thread occurs?

566


Why is a singleton bad?

552


Write a java program to check if a number is prime or not?

532


Is break statement can be used as labels in java?

495


How to stop a thread in java? Explain about sleep () method in a thread?

575






What is the role of garbage collector in java?

483


What is an example of a conditional statement?

560


What is the purpose of extern variable?

526


What are advantages and disadvantages of OOPs?

619


What is the gregoriancalendar class in java programming?

562


What is size_t?

499


What is annotation in java?

569


How to create a thread in java?

596


What is java thread dump, how can we get java thread dump of a program?

561


Why wait and notify methods are declared in object class?

597