What is the Difference between Checked and Unchecked exceptions?
Checked exceptions are instances of Exception class or its subclasses. Unchecked exceptions are instances of either Error class, Runtime Exception or its subclasses. We have to catch and handle the checked exceptions, or declare that we can't handle that exception. Compiler will check that we have done one of the two things. So, they are called checked exceptions.
The reason for this is that Errors are occur by conditions outside of the application. and Runtime Exceptions are occur by wrong programming logic. We can't handle these exceptional conditions without stopping the application. So, compiler will not ask you to catch or declare these types of exceptions, even though you can choose to do catch or declare.
Even when you are creating your own exception classes, you have to remember the intentions of checked exceptions, and unchecked exception classes.
Java Search Engine
Tuesday, October 23, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment