Sr.Java Web Developer Question:

Do you know how to create a custom Exception?

Sr.Java Web Developer Interview Question
Sr.Java Web Developer Interview Question

Answer:

To create you own exception extend the Exception class or any of its subclasses.

☛ class New1Exception extends Exception { } // this will create Checked Exception
☛ class NewException extends IOException { } // this will create Checked exception
☛ class NewException extends NullPonterExcpetion { } // this will create UnChecked exception


Previous QuestionNext Question
Tell us what is difference between Error and Exception?Please explain can we write multiple catch blocks under single try block?