Back to articles
Java Exception Handling:

Java Exception Handling:

via Dev.to BeginnersHayes vincent

What is an Exception? An exception is an unwanted or unexpected event that occurs during the execution of a program, which disrupts the normal flow of instructions. In simple terms: It is a runtime error that can crash your program if not handled properly. Real-Life Examples Dividing a number by zero Accessing an invalid array index Opening a file that doesn’t exist πŸ”Ή Exception Hierarchy in Java All exceptions in Java follow a structured hierarchy under Throwable Class Object └── Throwable β”œβ”€β”€ Exception β”‚ β”œβ”€β”€ Checked Exceptions β”‚ └── Unchecked Exceptions (RuntimeException) └── Error πŸ”Έ Important Concept Most exceptions are derived from Exception Error represents serious system-level problems (not usually handled) ** Types of Exceptions** 1. Checked Exceptions Checked at compile time Must be handled using try-catch or throws Example: IOException SQLException ** 2. Unchecked Exceptions (Runtime Exceptions)** Occur at runtime Not mandatory to handle Example: ** ArithmeticException NullPoin

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
7 views

Related Articles