Menu

Wednesday, 10 December 2014

Write a Program on an Exception Handling.

class MyException
  {
public static void main(String args[])
       { 
try
                {
                                int a = args.length;
                                int b = 42/a;
                                int c[] = {1};
                                c[50] = 25;
                }

                catch(ArithmeticException e)
                {
                System.out.println("DIVIDE BY:" + e);               
                }

                catch(ArrayIndexOutOfBoundsException e)
                {
                System.out.println("ARRAY INDEX:" + e);        
                }              
               
                finally
                {
                System.out.println("FINISHED");       
                }
       }
  }


OUTPUT : 

No comments:

Post a Comment