Write a program in java to demonstrate exception handling with multiple catch block?

class ExceptionHandling

{

      public static void main(String arg[])

      {

            try

            {

                  int a=Integer.parseInt(arg[0]);

                  int b=Integer.parseInt(arg[1]);

                  System.out.println(a/b);

            }

            catch(ArithmeticException e)

            {

                  System.out.println(e);

            }

            catch(ArrayIndexOutOfBoundsException e)

            {

                  System.out.println(e);

            }

            catch(NumberFormatException e)

            {

                  System.out.println(e);

            }

            catch(Exception e)

            {

                  System.out.println(e);

            }

            System.out.println("Normal Flow");

      }

}

Exception Handling Multiple Catch Block.PNG

, , , , , , , ,

Leave a Reply