Junior — Middle
What does an unchecked exception class that extends the Exception class mean?
sobes.tech AI
Answer from AI
In Java, checked and unchecked exceptions are divided as follows:
- Checked exceptions inherit from
Exceptionbut not fromRuntimeException. The compiler requires these exceptions to be handled in a try-catch block or declared in the method signature withthrows. - Unchecked exceptions inherit from
RuntimeExceptionorError. They do not require explicit handling or declaration.
If an exception class extends Exception but not RuntimeException, it is a checked exception. This means that when using such an exception in code, it must be explicitly handled or declared, helping developers anticipate errors and improve program reliability.