✏️ Explanatory Question
| Basis | Exception | Error |
|---|---|---|
| Meaning | Represents conditions that a program might want to catch and handle. | Represents serious problems that are not expected to be caught by applications. |
| Recoverable | Usually recoverable through proper error handling. | Non-recoverable, should not be handled in code. |
| Examples | IOException, SQLException, NullPointerException |
OutOfMemoryError, StackOverflowError, VirtualMachineError |
| Class Hierarchy | Subclass of Throwable → Exception |
Subclass of Throwable → Error |
Explanation:
Exceptions represent minor issues (like missing files, wrong input, etc.) that can be handled in code.
Errors represent serious system-level issues (like memory failure) that are typically beyond the program’s control.