What are Checked and UnChecked Exception? Ans. A checked exception is some subclass of Exception (or Exception itself), excluding class Runtime Exception and its subclasses. Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. Example: IOException thrown by java.io.FileInput Stream's read() method· Unchecked exceptions are Runtime Exception and any of its subclasses. Class Error and its subclasses also are unchecked. With an unchecked exception, however, the compiler doesn't force client programmers either to catch the exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. Example: String Index Out Of Bounds Exception thrown by String's charAt() method· Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be. - Study24x7
Social learning Network
18 Nov 2023 11:31 AM study24x7 study24x7

What are Checked and UnChecked Exception? Ans. A checked exception is some subclass of Exception (or Exception itself), excluding class Runtime Exception and its subclasses. Making an exception checked forces client programmers to deal with the possibility that the exception wil...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles