What is the diffrence between Checked Exception and unchecked Exception. is that runtime exceptions are unchecked Exceptions and they are derived from RuntimeException.
Checked Exceptions are always checked by the Compiler. The compiler throws errors if the Checked exceptions are not handled or declared.
Unchecked Exceptions on the other hand are not checked by the compiler and yes, they are subclasses of RuntimeException. Whether you choose to handle or declare them, the compiler doesn't care.
All throws exception are Checked Exception.Compiler makes sure that a block capable of throwing a CheckedException must/should associate a handler for it.Which if neglected would generate a compile-time error. Example : Block having a Class.forName("class name") statement should throw(s) ClassNotFoundException. Neglecting a handler for Unchecked exception doesn't worry compiler.
Hi Ashok, IllegalArgumentException is definetly an Unchecked Runtime Exception,which would prop-up during runtime when when a method is invoked with an argument which it can not reasonably deal with. Check for categorised exceptions,you will know the list.
Is that mean all the checked Exceptions are not RuntimeException and they are not either direct subclass or subclass of subclasses. [ June 30, 2008: Message edited by: Ashok Pradhan ]
Yes - Any exception that has RuntimeException as a superclass (either direct or higher up the inheritance chain) is an unchecked exception, and other exceptions are checked exceptions.