Menu
Question Index
...

In which order will the lines appear in the output of this program? Or does it not compile?

public class SecondException
{
    public static void main(String args[])
    {
        try
        {
            int i = 21 / 0;
            System.out.println(i);
        }
        catch (NullPointerException 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......
java.lang.ArithmeticException: / by zero
finally block is executed
Compilation Error for some other reason

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