Menu
Question Index
...

Given that the exceptions AEx, BEx and CEx are defined as shown below, which of the methods in RuntimeExceptions fails to compile.

class AEx extends RuntimeException {}
class BEx extends Exception {}
class CEx extends AEx {}

class RuntimeExceptions {

    void m1() throws AEx, BEx, CEx { }

    void m2() throws Exception { throwB(true); throwAC(false); }

    void m3() { throwAC(false); }

    void m4() throws AEx, BEx { throwAC(true); }

    void m5(boolean value) {
        try {
            throwB(value);
        } catch (Exception ex) {
        } finally {
            throwAC(false);
        }
    }

    void throwB(boolean value) throws CEx, BEx {
        if (!value) throw new BEx();
    }

    void throwAC(boolean value) {
        if (!value) throw new AEx();
        throw new CEx();
    }
}


m1, m5
m1, m2, m3, m4, m5
m2, m4, m5
m3, m5
All of them compile with out any errors

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