AIM: Write a program in Java to demonstrate multiple try block and multiple catch exception.
MultipleTryCatch.java
Output
Happy Coding :)
MultipleTryCatch.java
class MultipleTryCatch { public static void main(String arg[]) { int arr[]=new int[5]; try { try { System.out.println("Divide 1"); int b=23/0; } catch(ArithmeticException e) { System.out.println(e); } try { arr[7]=10; int c=22/0; System.out.println("Divide 2 : "+c); } catch(ArithmeticException e) { System.out.println("Err:Divide by 0"); } catch(ArrayIndexOutOfBoundsException e) //ignored { System.out.println("Err:Array out of bound"); } } catch(Exception e) { System.out.println("Handled"); } } }
Output
multiple try catch in java by practical server |
Happy Coding :)
0 Comments
Post a Comment