Home > DeveloperSection > Interviews > Explain the user defined Exceptions?

Posted on    January-29-2011 12:00 AM

 Java Java 
Ratings:
 1 Answer(s)
  1002  View(s)
Rate this:

Amit Singh

Total Post:565

Points:2825
Posted on    January-29-2011 1:00 AM

User defined Exceptions are the separate Exception classes defined by the user for specific purposed. An user defined can created by simply sub-classing it to the Exception class. This allows custom exceptions to be generated (using throw) and caught in the same way as normal exceptions.
Example:
class myCustomException extends Exception {
     // The class simply has to exist to be an exception
}

Don't want to miss updates? Please click the below button!

Follow MindStick