What is user defined exception

Showing Answers 1 - 2 of 2 Answers

yogeshpanda

  • Sep 22nd, 2005
 

Exceptions that the user want to be invoked when a particular criteria is not satisfied by the user.Eg. If the programmer want the user to give username necessarily,Then he can make an exception that if a user didnt give username then this exception is invoked.For this,1st we have to make an exception class of our own which mst will extend Exception class.Then make use of it in try,catch & use throw for throwing it explicitly.

  Was this answer useful?  Yes

pdommara

  • Sep 6th, 2007
 

You can create your own exception by extending the java.io.Exception.
Throw the that exception using throw like this :
public void method() throws userDefinedException {
try {
}catch(exception e) {
throw new userDefunedExcpetion();
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions