User Defined Exception or custom exception is creating your own exception class and throws that exception using ‘throw’ keyword. This can be done by extending the class Exception.
There is no need to override any of the above methods available in the Exception class, in your derived class. But practically, you will require some amount of customizing as per your programming needs.
Example: To created a User-Defined Exception Class
Step 1) Copy the following code into the editor
Step 2) Save , Compile & Run the code. Excepted output -
The keyword “throw” is used to create a new Exception and throw it to the catch block.