Search

Useful Links

Monday, February 1, 2010

Java Exceptions

What is an Exception ?
An exception is an abnormal condition that arises in a code sequence at run time. In other words, an exception is a run-time error.

What is a Java Exception ?
A Java exception is an object that describes an exceptional condition i.e., an error condition that has occurred in a piece of code. When this type of condition arises, an object representing that exception is created and thrown in the method that caused the error by the Java Runtime. That method may choose to handle the exception itself, or pass it on. Either way, at some point, the exception is caught and processed.

Where does Exception stand in the Java tree hierarchy ?
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.Error

What are checked exceptions ?
Checked exception are those which the Java compiler forces you to catch. e.g. IOException are checked Exceptions.

What are runtime exceptions ?
Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.

No comments:

Post a Comment