While defining an user defined exception, we need to take care of the following aspects:
- The user defined exception class should extend from Exception class.
- The toString() method should be overridden in the user defined exception class in order to display meaningful information about the exception.
Let us see a simple example to learn how to define and make use of user defined exceptions.