Try & Catch Block2846 - Java Quiz Question


What will be the output of the following program?

class Abcd extends Exception {    }
class Efgh extends Exception {    }
class Ijlk extends Exception {    }
class Kids {
    public static void main(String s[]) throws Abcd, Efgh, Ijlk {
        System.out.println("Before Abcd");
        methodA(true);
        System.out.println("Before Efgh");
        methodB(false);
        System.out.println("Before Ijkl");
        methodC(true);
    }
    public static void methodA(boolean value) throws Abcd {
        try {
            if (value)    throw new Abcd();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    public static void methodA(boolean value) throws Abcd {
        try {
            if (value)    throw new Abcd();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    public static void methodB(boolean value) throws Efgh {
        try {
            if (!value)    throw new Efgh();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    public static void methodC(boolean value) throws Ijlk {
        if (!value) throw new Ijlk();
    }
}


A
Before Abcd
Before Efgh
Before Ijkl
B
Before Abcd
Before Efgh
Efgh
Before Ijkl
C
Before Abcd
Abcd
Before Efgh
Efgh
Before Ijkl
Ijkl
D
Before Abcd
Abcd
Before Efgh
Efgh
Before Ijkl
E
Before Abcd
Before Efgh
Efgh
Before Ijkl
Ijkl
F
Compilation Error or Runtime Error