Error and Exception

Java异常处理详解
本文探讨了Java中的异常处理机制,解析了Error与Exception的区别及如何正确处理不同类型的异常。文章指出,catch子句可以捕获及其子类的异常,而不需要将抛出Error或RuntimeException的语句置于try块中。

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).

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值