Given that IllegalArgumentException extends RuntimeException, and given:
11. static String s = ""; 12. public static void main(String[] args) { 13. try { m(); } 14. catch (Exception ex) { s += "c1 "; } 15. System.out.println(s); // www. ja va2 s . co m 16. } 17. static void m() throws RuntimeException { 18. try { 19. s += "t1 "; 20. throw new IllegalArgumentException(); 21. } 22. catch (IllegalArgumentException ie) { s += "c2 "; } 23. throw new IllegalArgumentException(); 24. }
What is the result?
D is correct.
The first exception is handled in m()
; the second is declared in m()
and handled in main()
.