When does things go wrong?

  1. User Input → Enter invalid inputs
  2. Device Errors → Printer jams, network connection drops.
  3. Resource Limitations → Disk Full
  4. Code Errors→ Invalid array index, key not present in hash table, refer to a variable that is null , divide by zero,…

Exception Handling


Java’s Classification of Errors

<aside> 💡 All exceptions descend from the class Throwable.

</aside>


  1. Error → Relatively rare → Not the programmer’s fault.
    1. Internal errors, resource limitations within Java Runtime.
    2. No realistic correction action is possible, notify the caller and terminate gracefully.
  2. Exception→ Has two sub branches.
    1. Runtime Exceptions and Checked Exceptions