Source of Question27.java


  1: //Question27.java
  2: 
  3: public class Question27
  4: {
  5:     public static void main(String[] args)
  6:     {
  7:         try
  8:         {
  9:             int n = 7;
 10:             if (n > 0)
 11:                 throw new Exception();
 12:             else if (n < 0)
 13:                 throw new NegativeNumberException();
 14:             else
 15:                 System.out.println("Hello!");
 16:         }
 17:         catch (NegativeNumberException e)
 18:         {
 19:             System.out.println("First catch.");
 20:         }
 21:         catch (Exception e)
 22:         {
 23:             System.out.println("Second catch");
 24:         }
 25:         System.out.println("End of code");
 26:     }
 27: }