i

JAVA Complete Course

Types Of Exceptions

Every exception is ancestor of Throwable class. From throwable we have two children: Exception and Error. Between them is major difference. An error is a situation which we should not handle and from error it is impossible to return to the normal path of application. An exception is a situation when something unexpected happen but we can deal with this situation, handle it, and return back to normal way of application.

Exceptions itself is divided into two main groups: Checked and Unchecked exceptions and between them is also noticeable difference. We can skip handling of unchecked exceptions while it is impossible to ignore checked exceptions, which means that the code segment which can cause checked exception must handle it or throw it back to upper level, otherwise we will get compilation error. This restriction doesn’t apply to unchecked exceptions. It is not mandatory to deal with unchecked exceptions but we always can do it. Runtime Exception is a child or an example of unchecked exceptions.  Any I/O exception is an ancestor of checked exceptions.