Java Exception Handling Assignment
Java Exception Handling Assignment
- Exception handling in Java is used to handle runtime errors, ensuring the normal flow of the
application.
- It prevents the abrupt termination of a program by providing mechanisms to deal with exceptional
situations.
Example:
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
- **Checked Exceptions**:
- The program must handle these exceptions using try-catch or by declaring them with `throws`.
- **Unchecked Exceptions**:
- **throw**:
- Example:
- **throws**:
- It informs the caller of the method about the exceptions that might be thrown.
- Example: