Error and Exception

来源:互联网 发布:网络小胖卡通头像 编辑:程序博客网 时间:2024/06/04 19:46

Which statement is true?

A. catch(X x) can catch subclasses of X.

B. The Error class is a RuntimeException.

C. Any statement that can throw an Error must be enclosed in a try block.

D. Any statement that can throw an Exception must be enclosed in a try block.

 

E. Any statement that can throw a RuntimeException must be enclosed in a try

block.

 

Answer: A

 

 

 

Error and Exception are subclasses of Throwable.

RuntimeException is a subclass of Exception.

statements that throw Error do not need to be in a try block.

statemens that throw RuntimeException do not need to be in a try block (but other Exceptions have to be).

 

原创粉丝点击