Checked — compile-time check. Unchecked — runtime exceptions.
Checked exceptions:
1// Checked exception2public void readFile() throws IOException {3 // Must declare or catch4 throw new IOException("File not found");5}67// Must handle8try {9 readFile();10} catch (IOException e) {11 e.printStackTrace();12}
Unchecked exceptions:
1// Unchecked exception2public void divide(int a, int b) {3 if (b == 0) {4 throw new ArithmeticException("Division by zero");5 }6}
Examples: