What is the difference between checked and unchecked exceptions?

Beginner

Answer

Checked Exceptions: Must be caught or declared in method signature. Checked at compile-time.
Examples: IOException, SQLException, ClassNotFoundException
Unchecked Exceptions: Runtime exceptions that don't need to be caught or declared.
Examples: NullPointerException, ArrayIndexOutOfBoundsException, IllegalArgumentException

// Checked exception - must handle
public void readFile() throws IOException {
    FileReader file = new FileReader("file.txt");
}
// Unchecked exception - optional handling
public void divide(int a, int b) {
    int result = a / b; // May throw ArithmeticException
}