Due to some problem at javaranch site I was unable to see the reply for my post so I am posting my question again Please answer. What are the checked exceptions ? How these are different from run time exceptions ? Please explain them in detail and also give examples of both type of exceptions ?
Checked exceptions are those which are checked by the compiler for proper exception handling. ie., the code that throws a checked exception must be enclosed in a try-catch-finally block and/or itself must be declared in the throws clause. All exceptions that are subclass of java.lang.Exceptionbut are not subclass of java.lang.RuntimeException are checked exceptions. Examples include IOException, AWTException, SQLException etc. Runtime exceptions are subclasses of java.lang.RuntimeException and they are also called unchecked exceptions. It is not required to either declare them in the throws clause or enclose the throwing code in the try-catch-finally block. java.lang.Error and its subclasses are also unchecked throwables. Usually these indicate unrecoverable error conditions in the program and hence you don't really benefit from catching them. Examples include ArithmeticException, ClassCastException, IndexOutOfBoundsException, VirtualMachineError etc. I suggest you go through the API documentation for more information. Also read JLS Section 11 Exceptions that has a very detailed description about checked and unchecked exceptions. Hope that helps! ------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).