Thursday, December 10, 2009

Exception handling

An intelligent and effective coding includes "Exception handling". Java includes three types of exceptions checked exceptions, un-checked exceptions & error.

Checked exceptions : Exceptions which are sub class of the java.lang.Exception (eg: IOExceptions)
Un-checked exceptions : Exceptions which are sub class of the java.lang.RuntimeException (eg: NullPointerException)
Error : Exceptions which are sub class of the java.lang.Error (eg: AssertionError)

In an application only three styles of exception handling can be implemented
  1. Do not handle any exceptions.
  2. Handle the exceptions in a haphazard way.
  3. Handle the exception in an intelligent way.
Though one can easily conclude in an application the exception is handled or not but it is left to the reader to decide whether it is haphazard or intelligent way of handling the exceptions. You can find one of the good in detailed example on the exception handling here. Also, check this "An Exception Handling Framework for J2EE Applications".

No comments:

Post a Comment