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.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты