Java provides a way to define our own exceptions. It is good practice to defined the custom(user-defined) exceptions for every application. This helps in handling exceptions better and pass additional information along with exception. The hierarchy of custom exceptions can help taking appropriate actions at various module levels.
We can define custom exceptions by simply extending from the class
If we are dealing with railway reservation application, it might have custom exceptions like
The topic Java Throw Keyword - Java Throws Keyword explains how the user defined exceptions can be created and how they can be thrown.