Given the following code

public class OverrideThrowsTest {
    public static void main(String[] args)
        // 1
    {
        A a = new A();
        a.method();
        A ab = new B();
        ab.method();
        B b = new B();
        b.method();
    }
}

class A {
    public void method() throws IOException {}
}

class B extends A {
    public void method() throws FileNotFoundException {}
}
Select all the answers, for which, if placed into line 1, code will compile.
Explanation
FileNotFoundException extends IOException,
IOException extends Exception. Such throws that would cover all the possible exceptions should be declared - IOException and Exception in this case.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes