What Are Userdefined Exceptions In Java And What Is The Use?


2 Answers

Akshay Kalbag Profile
Akshay Kalbag answered
The term user-defined exceptions when used in the context of the Java programming language, as the name suggests, are those exceptions which are created and defined by the users of the Java programming language. Programmers create user-defined exceptions which are specific to their business in the Java programming language.

For example, if the person is in the business of selling motorcycles and need to validate an order which has been placed by a customer, creating a user-defined exception in the Java programming language can be done by a creating a new class which can be named TooManyBikesException. This has been derived from the class exception or throwable, and if someone tries to place an order for more motorcycles than you can ship, you can simply throw a user-defined exception.

One general instruction is that if you want to create a user-defined exception in the Java programming language, it is important to create your program in such a way that is not only robust, but it is also easy to debug.
mahamood akhtar Profile
mahamood akhtar answered
UserDefined Exceptions are any subcalss of Exception which is defined by a user to define their own exceptional condition.

Answer Question