Home › coding › java › java exceptions

Java Exceptions — Free Java Tutorial

Learn Java Exceptions in Java with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

✓ 100% Free ✓ No Login Needed ✓ NCERT / CBSE Aligned ✓ Download as PDF

TL;DR: Learn Java Exceptions in Java with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated Jul 14, 2026

🤖 Stuck on any question? Ask Syllab's free AI Tutor for a step-by-step explanation — instant, unlimited, no login.

Java Exceptions in Java

An exception is an unexpected event that disrupts normal program flow: dividing by zero, accessing a null reference, reading a file that doesn't exist. Java has a robust exception handling system using try-catch-finally blocks.

try: code that might throw an exception. catch: what to do when a specific exception occurs. finally: code that ALWAYS runs (use for cleanup — closing files, connections). throw: manually throw an exception. throws: declare that a method might throw an exception.

Checked exceptions (must be handled — IOException, SQLException) vs Unchecked exceptions (extend RuntimeException — NullPointerException, ArrayIndexOutOfBoundsException, NumberFormatException). Understanding the difference is important for Java exams.

Java Exceptions — Syntax

try {
    // risky code
} catch (ExceptionType e) {
    // handle error
    System.out.println(e.getMessage());
} finally {
    // always executes
}

Learn Java Exceptions step by step with Syllab's free interactive Java tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full Java course →

Explore:

  • Syllabus
  • Practice
  • Mock Tests
  • NCERT Solutions
  • Coding
  • GK Quiz
  • Career Predictor
  • AI Tutor
  • Live Quiz
  • Doubt Solver
  • Microlearning
  • Free Alternatives
  • Kids Zone
  • Study Room
  • Calculators
  • Worksheets

Syllab.in — Free learning for Indian students, Class 1–12