What is the difference between Exception and Error?
Long Answer
Views 26
Answer:
| 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.
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.