Oracle
1Z0-851 · Question #47
Given: static void test() throws Error { if (true) throw new AssertionError(); System.out.print("test "); } public static void main(String[] args) { try { test(); } catch (Exception ex) {…
The correct answer is E. A Throwable is thrown by main. See the full explanation below for the reasoning.
Question
Given: static void test() throws Error { if (true) throw new AssertionError(); System.out.print("test "); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print("exception "); } System.out.print("end "); } What is the result?
Options
- Aend
- BCompilation fails.
- Cexception end
- Dexception test end
- EA Throwable is thrown by main.
- FAn Exception is thrown by main.
How the community answered
(30 responses)- A10% (3)
- B3% (1)
- E83% (25)
- F3% (1)
Community Discussion
No community discussion yet for this question.