jain12

Exception handling doubt 1

Jun 5th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. /*
  6. class Test{                     //error: Test.java:10: error: unreported exception IllegalAccessException; must be caught or declared to be thrown  in met();
  7.   public static void met ()throws IllegalAccessException{
  8.       try{
  9.            throw new  IllegalAccessException("demo");
  10.            }
  11.       catch(ArithmeticException e){
  12.           System.out.println("  arithmetic ");
  13.           }
  14.        }
  15.   public static void main(String args[]){
  16.      met();
  17.     }
  18.   }
  19. */
  20.  
  21. /*
  22.   class Test{    //error  : unreported exception IllegalAccessException; must be caught or declared to be thrown  in met();
  23.     public static void met ()throws IllegalAccessException{
  24.        throw new  IllegalAccessException("demo");
  25.        }
  26.   public static void main(String args[]){
  27.     try{
  28.          met();
  29.         }
  30.     finally{
  31.       System.out.println("  arithmetic ");
  32.       }
  33.     }
  34.   }
  35. */
Add Comment
Please, Sign In to add comment