Menu
Question Index
...

What will be the output of the following program?

public class ThirdException
{
    public static void main(String args[])
    {
        try
        {
            int i = 21 / 0;
            System.out.println(i);
        }
        catch (ArithmeticException e)
        {
            System.out.println(e);
        }
        finally
        {
            System.out.println("finally block is executed");
        }
        System.out.println("Rest of the code......");
    }
}


finally block is executed
java.lang.ArithmeticException: / by zero
Rest of the code......
finally block is executed
java.lang.ArithmeticException: / by zero
java.lang.ArithmeticException: / by zero
finally block is executed
Rest of the code......
21
finally block is executed
Rest of the code......

Doubts

Problems

Topic: Java Finally Block In Exception Handling

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App