Thursday, 8 March 2012

Types of Exceptions


•There is another classification of exceptions based on whether Java’s compiler, checks, whether the method raising the exceptions is providing the handler or not.
•Uncheked Exceptions: Java’s compiler doesn’t check for handlers.
•Checked Exceptions: Java’s compiler checks whether the handlers for the exceptions are provided or not.
•All classes of “RuntimeException” and “Error” are unchecked exceptions.
•All Checked Exceptions that are to be raised in a method, must be provided beside the “throws” keyword.
•All the subclasses of “Error” and “RuntimeException” are unchecked exceptions.

Uncaught Exceptions:

•If in your program, a statement or set of statements raises a run-time error (exception) and no code is provided to handle that exception, then Java run-time system will invoke the default handler for handling the exception based on the type of exception thrown.
•The default handler prints a stack trace which contains: the type of exception, the method in which exception is thrown and the line number at which the exception is thrown.


Java’s Built-in Exceptions: 



No comments:

Post a Comment