Menu
Question Index
...

What will be the output of following program?

public class Retrospective {
    public static void main(String args[]) {
        try {
            try {
                System.out.print("Print 0-");
                int b = 100 / 0;
            } catch (ArithmeticException e) {
                System.out.print("Catch 0-");
            }
            try {
                int a[] = new int[3];
                a[3] = 4;
            } catch (ArrayIndexOutOfBoundsException e) {
                System.out.print("Catch 1-");
            }
            System.out.print("Printed 1-");
        } catch (Exception e) {
                System.out.print("Catch 2-");
        }
        System.out.print("Printed 2-");
    }
}


Print 0-Catch 0-Catch 1-Printed 2-
Catch 0-Catch 1-Printed 2-
Print 0-Catch 0-Printed 1-Printed 2-
Print 0-Catch 0-Catch 1-Printed 1-Printed 2-
Some other output
Compilation Error or Runtime Error other output

Doubts

Problems

Topic: Exception Handling Syntax In Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App