Я пытался решить этот пример вопроса для экзамена OCA Java SE 8, но ошибся.
Код: Выделить всё
public static void main(String... a) {
System.out.print("a");
try {
System.out.print("b");
throw new IllegalArgumentException("1");
} catch (IllegalArgumentException e) {
System.out.println("c");
throw new RuntimeException("1");
} catch (RuntimeException e) {
System.out.println("d");
throw new RuntimeException("2");
} finally {
System.out.print("e");
throw new RuntimeException("3");
}
}
I believe the answer should be:
Код: Выделить всё
abcdeException in thread "main" java.lang.RuntimeException: 3
Код: Выделить всё
abceException in thread "main" java.lang.RuntimeException: 3
Код: Выделить всё
IllegalArgumentExceptionКод: Выделить всё
RuntimeExceptionКод: Выделить всё
RuntimeExceptionКод: Выделить всё
RuntimeExceptionКод: Выделить всё
RuntimeException("3")Therefore,
Код: Выделить всё
abcdeException in thread "main" java.lang.RuntimeException: 3Am I missing anything in terms of reasoning? How should my sequence of thoughts be instead?
Источник: https://stackoverflow.com/questions/781 ... exceptions
Мобильная версия