Menu
Question Index
...

What will be the output of the following program?

public class Exceptions {
    public static void main(String[] args) {
        int Numerator = 20, numerator = 0;;
        int Denominator = 0, denominator = 20;
        try {
            System.out.println(Numerator / Denominator);
        } catch (ArithmeticException e) {
            System.out.println("Denominator should not be 0 incase of integer division");
        }
        try {
            System.out.println(numerator / denominator);
        } catch (ArithmeticException e) {
            System.out.println("numerator should not be 0 incase of integer division");
        }
    }
}


Denominator should not be 0 incase of integer division
numerator should not be 0 incase of integer division
0
numerator should not be 0 incase of integer division
Denominator should not be 0 incase of integer division
0
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Built In Exceptions Checked Exceptions, Unchecked Exceptions

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App