Checked Exceptions vs. Unchecked Exceptions

Checked Exceptions vs. Unchecked Exceptions.



Checked Exceptions

- A checked exception is a subclass of Exception excluding class RuntimeException and its subclasses.
- Compiler checks to see if these exceptions have been properly caught or not else the code doesn't compile. Thus, a program is forced to deal with the situations where an exception can be thrown.
- Checked exceptions must be either declared or caught at compile time.

Unchecked Exceptions

- Unchecked exceptions are RuntimeException and all of its subclasses along with class java.lang.Error and its subclasses also are unchecked.
- A program does compile without these exceptions being handled during compile time.
What is a user defined exception?
What is a user defined exception? - At times, depending on the need of a program, a programmer might need to create his own set of exceptions...
What are the different ways to generate an Exception?
Different ways to generate an Exception - There are 3 ways in which the exceptions are generated:...
How are try, catch and finally block organized?
How are try, catch and finally block organized? - The try block is the region of code where exceptions can get produced. So most of the code of execution lies in this region...
Post your comment