ariestamirra

demo

May 22nd, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package Percobaan;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. class ExceptionA extends Exception {
  6. }
  7.  
  8. class ExceptionB extends ExceptionA {
  9. }
  10.  
  11. class ExceptionC extends ExceptionB {
  12. }
  13.  
  14. public class Demo {
  15.  
  16.     public static void main(String args[]) {
  17.         try {
  18.             throw new ExceptionC();
  19.         } catch (ExceptionA a) {
  20.             JOptionPane.showMessageDialog(
  21.                     null, a.toString(), "Exception",
  22.                     JOptionPane.INFORMATION_MESSAGE);
  23.         }
  24.         try {
  25.             throw new ExceptionB();
  26.         } catch (ExceptionA b) {
  27.             JOptionPane.showMessageDialog(
  28.                     null, b.toString(), "Exception",
  29.                     JOptionPane.INFORMATION_MESSAGE);
  30.         }
  31.         System.exit(0);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment