1 try – multiple catch handling

1 try – multiple catch handling is maximum use program in java. In this example we will work on ArrayIndexOutOfBoundsException, ArithmeticException and normal Exception.

Here we create one try block with three catch block with three different run time errors.


Let’s see 1 try – multiple catch program with videos


class Exc4


            public static void main(String args[])


                        int x[] = new int[2];




                                    x[0] = 23;

                                    x[1] = 0;

                                    //x[2] = 12;      // ArrayIndexOutBoundsException


                                    int div = x[0]/x[1];      // ArithmeticException

                                    System.out.println(“Div = ” + div);


                        catch(ArrayIndexOutOfBoundsException ex)




                        catch(ArithmeticException ex)





                        catch(Exception ex)







Output -1

If we use x[2] = 12 line in program then we found ArrayIndexOutOfBoundsException


Output -2

If we do not use x[2] = 12 line in program then we found ArithmeticException.




Video available on YouTube now.


If you have query about this blog, you can directly post comment or subscribe on website.

Earn money online

500total visits,1visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.


Link back if you want.

Enter Captcha Here :*

Reload Image