Question: What would be the output of following program. class Base extends Exception {} class Derived extends Base {} public class Main { public static void
What would be the output of following program.
class Base extends Exception {} class Derived extends Base {} public class Main { public static void main(String args[]) { // some other stuff try { // Some monitored code throw new Derived(); } catch(Base b) { System.out.println("Caught base class exception"); } catch(Derived d) { System.out.println("Caught derived class exception"); } } }
| Caught base class exception |
| Caught derived class exception |
| Compiler Error because derived is not throwable |
| Compiler Error because base class exception is caught before derived class |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
