SCJP 1.6版考題 136
出自 陳富國維基館
Given: 11. public static void main(String[] args){ 12. try{ 13. args = null; 14. args[0] = "test"; 15. System.out.println(args[0]); 16. }catch(Exception ex) { 17. System.out.println("Exception"); 18. }catch(NullPointerException npe){ 19. System.out.println("NullPointerException"); 20. } 21. } What is the result? A. test B. Exception C. Compilation fails. D. NullPointerException
解答
Ans: C
解說: 子類別例外應先於父類別例外catch
|