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.