Advertisement
drhn

L07-Q2

Feb 23rd, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. class Ex1 extends Exception {}
  2. class Ex2 extends Ex1  {}
  3.  
  4. class Q2 {
  5.   public static void main(String args[]) {
  6.    // some other stuff
  7.    try {
  8.        // Some monitored code
  9.        throw new Ex2();
  10.     }
  11.     catch(Ex1 e)     {
  12.        System.out.println("Caught Ex1 exception");
  13.     }
  14.     catch(Ex2 e)  {
  15.        System.out.println("Caught Ex2 exception");
  16.     }
  17.   }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement