InterviewSolution
| 1. |
What Is The Difference Between Checked Exception And Unchecked Exception? |
|
Answer» CHECKED Exception is a direct subclass of Exception where as unchecked exception is a subclass of RunTimeException. Checked exception should be wrapped in a try-catch block or SPECIFIED as THROWS clause where as there is no such requirement for unchecked exception. Failure to provide exception handling mechanism for checked exception result in compiler error whereas no compile time error for unchecked exception. Checked exceptions are DESIGNED to reduce the number of exceptions which are not properly handled and where there is a reasonable chance for recovery. UnCheckedExceptions are mostly programming errors. Checked Exception is a direct subclass of Exception where as unchecked exception is a subclass of RunTimeException. Checked exception should be wrapped in a try-catch block or specified as throws clause where as there is no such requirement for unchecked exception. Failure to provide exception handling mechanism for checked exception result in compiler error whereas no compile time error for unchecked exception. Checked exceptions are designed to reduce the number of exceptions which are not properly handled and where there is a reasonable chance for recovery. UnCheckedExceptions are mostly programming errors. |
|