An exception is an event or condition that interrupts the normal flow of program execution. It occurs when something unexpected or erroneous happens, and it can be caught and handled in code to prevent the program from crashing.
Related terms
Checked Exception: Exceptions that must be declared explicitly in a method's signature or handled using try-catch blocks during coding.
Unchecked Exception (RuntimeException): Exceptions that do not require explicit declaration or handling, usually caused by logical errors in the code like divide-by-zero or accessing null objects.
Error: Fatal exceptions that occur due to serious problems outside the control of the application, such as hardware failures or out-of-memory situations. Errors should not be caught and generally cause termination of the program.