Exceptions Hierarchy
Object
|
Throwable
|
-------------------------------------------------
| |
Error (Unchecked) Exception(Checked)
|
-----------------------------------------
| | |
RuntimeException(Unchecked) Other1(Checked) Other2(Checked)...
Checked Exceptions
Checked at compile time. If a code within a method throws a checked exception, then the method must either catch that exception or it must specify that (using throws) that this exception is being thrown from this method and the caller must handle it or throw forward.
Unchecked Exceptions
Not checked at compile time. Because we don’t know what Error or RuntimeException will happen. The compiler does not require us to catch or specify runtime exceptions, but we can catch or specify them.
e.g. Error -> StackOverflowError, OutOfMemoryError
RuntimeException -> NullPointerException, IllegalArgumentException, ArrayIndexOutOfBoundException
In C++ world all exceptions are unchecked.