Computer Science, asked by choteandbade1626, 1 year ago

How can we create our own exception ? Explain with example.

Answers

Answered by Anonymous
0

Java provides us facility to create our own exceptions which are basically derived classes of Exception. For example MyException in below code extends the Exception class. We pass the string to the constructor of the super class- Exception which is obtained using “getMessage()” function on the object created.

Answered by anshi60
5

if you are creating your own exception that is known as custom exception or user defined exception.

by the help of custom exception you have your own exception or messages..

follow me

Similar questions