Have a Question?

If you have any question you can ask below or enter what you are looking for!

What is the checked and unchecked exception?

What are the checked and uncheched exception?
What is the checked and unchecked exception?

What is the checked and unchecked exception?

What is the checked and unchecked exception?
  • The exceptions which are checked by the compiler for smooth execution of the program are called checked exceptions.
  • In our program, if there is a chance of raising checked exception then compulsory we should handle that checked exception either by try-catch or by throws keyword otherwise we will get compile time error.
  • Unchecked exceptions are generated because of a programming error. They are not always caught by the program because they generally require a change by the programmer to be fixed.
  • Checked Exceptions are not the result of a programming mistake. Instead, they occur in the normal operation of a program. An example would be an IOException that is thrown when a file cannot be opened. Because these exceptions occur even if there is nothing wrong with the program, it is necessary to tell the program how to handle the exception.
  • Checked Exception is required to be handled by compile time while Unchecked Exception doesn’t.
  • Checked Exception is direct sub-Class of Exception while Unchecked Exception is of RuntimeException.
  • CheckedException represents scenario with higher failure rate while Unchecked exceptions mostly programming mistakes.
  • The exceptions which are not checked by compiler whether programmer handling or not. Such type of exceptions is called unchecked exceptions.
    • Example:- ArithmeticException, etc..
  • Note 1:- whether it is checked or unchecked every exception occurs at runtime only there is no chance of occurring any exception at compile time.
  • Note 2:- RuntimeException and its child classes, Error, and its child classes are unchecked Exceptions. Except these remaining are checked.

Leave a Reply

Your email address will not be published. Required fields are marked *