Answer
Checked exceptions are exception classes subject to compile-time catch-or-declare checking; unchecked exceptions are RuntimeException, Error, and their subclasses. • Checked exceptions often represent recoverable external failures. • Unchecked exceptions often represent programming errors or unrecoverable conditions, though this is a design convention. • The compiler rule follows the class hierarchy, not the message or cause.
Example
Code
try {
java.nio.file.Files.readString(java.nio.file.Path.of("missing.txt"));
} catch (java.io.IOException exception) {
System.out.println("handled");
}Output
handled
Quick Revision
The Throwable hierarchy determines whether an exception is checked.