Friday, May 29, 2009

checked and unchecked exceptions

Unchecked Exceptions: Exceptions that are defined by the Error and RuntimeException classes and their subclasses are known as unchecked exceptions. It is not necessary that a method must deal with these kinds of exceptions. If the exceptions are irrecoverable, the program should not attempt to deal with them. The method can only deal with the exceptions that are recoverable.

Checked Exceptions: All exceptions except the Error and RuntimeException classes and their subclasses are known as checked exceptions. If a method throws a checked exception, it is necessary that the method must explicitly deal with the exception. The method must catch the exception and take the necessary action.

No comments:

Post a Comment