Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CustomException checked or unchecked

Tags:

java

If I declare class

Class MyOwnException extends Exception
{
}

Is this is a checked or unchecked exception?

like image 896
jezhilvalan Avatar asked Jan 19 '26 09:01

jezhilvalan


1 Answers

If you extend Exception then it is "checked", i.e if you throw it, it must be caught or declared in the method signature.

Unchecked exceptions extend RuntimeException and do not need to be declared or caught. It is also possible to create an unchecked exception by extending Error or one of its subclasses, but these exceptions are by convention reserved for use by the JDK.

like image 129
Dean Povey Avatar answered Jan 21 '26 23:01

Dean Povey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!