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);
        }
        
        System.out.println("Rest of the code......");
    }
}


java.lang.ArithmeticException: / by zero
java.lang.ArithmeticException: / by zero
Rest of the code......
0
Rest of the code......

Compilation Error for some other reason

Doubts

Problems

Topic: Try Catch Block In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App