If I create an exception class that extends Exception, will my class be checked or dropped? I note that the subclass Exceptioncalled RuntimeExceptionis an unchecked exception, while all other subclasses of the βExceptionβ are marked with exceptions.
Exception
RuntimeException
If I create an exception class that extends RuntimeException, can I indicate that this class is checked?
1) Verified
2) No
If you added Exception -> checked
If you extend a RuntimeException -> unchecked
From the documentation:
{@code Exception} , * {@link RuntimeException} *
, RuntimeException Error
If you create a class that extends Exception, it will be checked. You cannot throw a RuntimeException as noted, as this is an exception.
If your class extends Exception, it can throw checked exceptions.
If your class extends a RuntimeException error or exception, it may throw thrown exceptions.