Exceptions and Generics
Exceptions
Throwable
Throwable has two subclasses: Exception and Error
The Error class represents serious errors that are generally not recommended to be caught with catch in our programs. We can only optimize Error by optimizing code. When Error occurs, JVM generally chooses to terminate the thread.
The Exception class has two subclasses: Checked Exception and Unchecked Exception.
Checked Exception indicates that the exception will be checked at compile time. If the exception is not caught with catch or declared with throws, it won’t pass compilation. This includes IOException, ClassNotFoundException.
Unchecked Exception indicates that it won’t be checked at compile time. It includes RuntimeException and its subclasses, such as NullPointerException, ArrayIndexOutOfBoundsException, and ClassCastException that may occur during forced type conversion.

