Menu
Question Index
...

What will be the output of the following program?

public class ExceptionExampleDemo {
    public static void main(String args[]) {
        int num1 = 10;
        int num2 = 0;
        int result = 0;
        int input[] = new int[5];
        try {
            input[0] = 0;
            input[1] = 1;
            input[2] = 2;
            input[3] = 3;
            input[4] = 4;
            input[5] = 5;
            result = num1 / num2;
            System.out.println("Result of Division : " + result);
        } catch (ArithmeticException e) {
            System.out.println("Err: Divided by Zero");
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("Err: Array Out of Bound");
        }
    }
}


Result of Division : 0
Err: Divided by Zero
Err: Array Out of Bound
Some other output

Doubts

Problems

Topic: Java Multiple Catch Block With Example Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App