Skip to content
CodeKruPro

Which blocks run when an exception is thrown?

Predict the outputEasyJava onlyAsked in: Capgemini, Wipro
Main.java
public class Main {
    public static void main(String[] args) {
        try {
            System.out.println("A");
            int x = 1 / 0;
            System.out.println("B");
        } catch (ArithmeticException e) {
            System.out.println("C");
        } finally {
            System.out.println("D");
        }
        System.out.println("E");
    }
}

Graded by exact match. Spaces at the ends of lines and blank lines at the end do not count.

to answer and keep your progress. Reading is free for everyone.