What will be printed to standard output stream if a tryThis() method throws an IOException?

try {
    tryThis();
    return;
} catch (IOException x1) {
    System.out.println("exception 1");
    return;
} catch (Exception x2) {
    System.out.println("exception 2");
    return;
} finally {
    System.out.println("finally");
}
Explanation
Only one catch block with the most specific matching exception will be executed, in this case it is catch (IOException x1) . Finally block is also executed, as it is executed always.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести