DEVFYI - Developer Resource - FYI

Explain the user defined Exceptions?

Java Interview Questions and Answers (part 3)

(Continued from previous question...)

386. Explain the user defined Exceptions?

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.
class myCustomException extends Exception {
// The class simply has to exist to be an exception

(Continued on next question...)

Other Interview Questions