Menu
Question Index
...

What will be the output of the following program?

public class Arithmetic {
    public static void main(String[] args) {
        int first = 20;
        int second = 0;
        int f = 0;
        int s = 20;
        try {
            System.out.println(first % second);
        } catch (ArithmeticException e) {
            System.out.println("second operand should not be 0 incase of modulo division");
        }
        try {
            System.out.println(f % s);
        } catch (ArithmeticException e) {
            System.out.println("first operand should not be 0 incase of modulo division");
        }
    }
}


0
first operand should not be 0 incase of modulo division
second operand should not be 0 incase of modulo division
0
second operand should not be 0 incase of modulo division
first operand should not be 0 incase of modulo division
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