[OCAJP]需要檢查的例外

Which two statements correctly describe checked exception?

A. These are exceptional conditions that a well-written application should anticipate and recover from.
B. These are exceptional conditions that are external to the application, and that the application usually cannot anticipate or recover from.
C. These are exceptional conditions that are internal to the application, and that the application usually cannot anticipate or recover from.
D. Every class that is a subclass of RuntimeException and Error is categorized as checked exception.
E. Every class that is a subclass of Exception, excluding RuntimeException and its subclasses, is categorized as checked exception.

題解

選項A,checked exception在撰寫程式的時候一定要被處理,所以這個敘述是正確的。

選項B,這是Error的敘述。

選項C,這是RuntimeException的敘述。RuntimeException為unchecked exception

選項D,RuntimeException和Error以及繼承它們的例外和錯誤都是unchecked exception才對。

選項E,除了RuntimeException和繼承RuntimeException的例外之外,Exception和其它繼承Exception的例外都是checked exception

關於作者

Magic Len

各位好,我是Magic Len,是這網站的管理員。我是台灣台中大肚山上人,畢業於台中高工資訊科和台灣科技大學資訊工程系,曾在桃機航警局服役。我熱愛自然也熱愛科學,喜歡和別人分享自己的知識與經驗。如果你有興趣認識我,可以加我的Facebook,並且請註明是從MagicLen來的。

相關文章