SCJP題庫第125題

Given:
33. try{
34.     //some code here
35. }catch(NullPointerException el){
36.    System.out.print("a");
37. }catch(Exception e2){
38.    System.out.print("b");
39. }finally{
40.    System.out.print("c");
41. }

If some sort of exception is thrown at line 34, which output is possible? (如果在第34行某種例外被丟出,那個輸出是可能的?)



A. a
B. b
C. c
D. ac
E. abc 

Ans: D

解說:
程式中發生某種例外,可能會由35或37行的例外補捉程序進行補捉(印出a或b),再加上Finally是必然執行 的區塊,所以輸出不是ac就是bc。

Comments

Popular posts from this blog

Android+Google Map API v3 Geocoding(地址轉經緯度度