Menu
Question Index
...

What will be the output of the following program?

public class FirstException
{
    public static void main(String args[])
    {
        try
        {
            int a[] = new int[5];
            a[5] = 30 / 0;
        }
        catch (Exception e)
        {
            System.out.println("Common task completed");
        }
        catch (ArithmeticException e)
        {
            System.out.println("Task1 is completed");
        }
        catch (ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Task2 is completed");
        }
        System.out.println("Remaining code");
    }
}


Task1 is completed
Task2 is completed
Common task completed
Remaining code
Common task completed
Remaining code
Task1 is completed
Remaining code
Task2 is completed
Remaining code
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Multiple Catch Block With Example Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App