李刚 发表于 2013-8-16 14:49:24

[Oracle interview]What are Checked and UnChecked Exception?

曹凯 发表于 2013-8-16 15:01:32

A checkedexception is some subclass of Exception (or Exception itself), excludingclass RuntimeException and its subclasses.Making an exception checked forcesclient programmers to deal with the possibility that the exception will bethrown. eg, IOException thrown by java.io.FileInputStream's read()method?       Unchecked exceptions areRuntimeException and any of its subclasses. Class Error and its subclassesalso are unchecked. With an unchecked exception, however, the compilerdoesn't force client programmers either to catch theexception or declare itin a throws clause. In fact, client programmers may not even know that theexception could be thrown. eg, StringIndexOutOfBoundsException thrown byString's charAt() method? Checked exceptions must be caught at compile time.Runtime exceptions do not need to be. Errors often cannot be.
页: [1]
查看完整版本: [Oracle interview]What are Checked and UnChecked Exception?