Java Exception Handling
Java Exception Handling
An error is a serious issue that occurs during program execution and cannot be handled by the program.
Types of Errors:
Exception Handling: Mechanism to detect, handle, and recover from exceptions during execution without
3. Types of Exceptions
a) Checked Exceptions
b) Unchecked Exceptions
c) User-defined Exceptions
Custom exceptions for specific use cases. Example: class AgeException extends Exception
Exception Handler: Block of code that handles exceptions using try, catch, finally, throw.
Types:
1. try-catch block
2. try-catch-finally block
4. Nested try-catch
5. throw keyword
6. throws keyword
Diagram: Java Exception Hierarchy
Throwable
Error Exception
Checked Exception
Unchecked Exception