ProLesson 5.1Intermediate3 min readUpdated 30 October 2026
Exceptions: checked vs unchecked
What an exception is, how Java's exception family tree is organised, and the difference between checked and unchecked exceptions.
An exception is Java's way of saying "something went wrong, and this code can't continue normally". A file is missing, a number can't be parsed, a network call times out. Instead of crashing silently or returning strange values, Java throws an exception object that describes the problem.
01What happens when nothing handles it
Uncaught.java
public class Uncaught {
public static void main(String[] args) {
System.out.println("Before");
int[] scores = {90, 80};
System.out.println(scores[5]); // index 5 doesn't exist
System.out.println("After"); // never reached
}
}Before Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 2
The exception travels up the call stack looking for code that handles it. If none does, the thread stops and Java prints the stack trace: the exception type, its message, and the chain of method calls that led to it. Reading stack traces top-down is a core debugging skill.
Loading the rest of the lesson…