Unit 2 home
Class 17 of 60 Part H · Slate UI24PC320CS
Placeholder · not written yet

Exceptions — what they are, the hierarchy, and checked vs unchecked

This is the page that turns "my program crashed" into "my program told me exactly what went wrong, and where". Classes 17 to 20 follow one running application — a campus food-ordering app — through its own real crash logs.

Class 17 Part H · C17–C20 12 pages planned 1 PYQ · P2·Q4

This session has not been authored yet

You have reached a real page, but an empty one. The deck for Class 17 is planned in full in the course knowledge document and is queued for authoring — nothing on this page is finished teaching content, and nothing below is a preview of it.

The roster underneath is the actual plan for this session, straight from the syllabus mapping — so you can see exactly what will land here, and revise the right things in the meantime.

What this class will cover

  1. Part-H openerThe slate arc across Classes 17–20, and the campus food-ordering crash-log spine that runs through all four.
  2. What an exception actually isA runtime error signal — and why Java refuses to just crash silently.
  3. Why exceptions, not error codesThe same failure a C function signals with -1 and a global errno, Java signals by throwing.
  4. The exception hierarchyThrowableError / ExceptionRuntimeException, drawn out in full.
  5. Checked vs uncheckedCompiler-enforced versus the RuntimeException family — the distinction the exam keeps asking about.
  6. PYQ · P2·Q4 · 2 marksDifferentiate checked and unchecked exceptions, with examples.
  7. The five you will actually meetNullPointerException, ArrayIndexOutOfBoundsException, ClassCastException, NumberFormatException, ArithmeticException.
  8. Worked example — all five, for realOne small program triggers each in turn, with the genuine terminal message for every one.
  9. Activity 1 · classify the crash logFive real crash lines from the food-ordering app — name the exception in each.
  10. Activity 2 · match exception to causeSix crash lines matched to what actually caused them, then the Class-17 close card.

Where this picks up from

Lab 3 left a deliberate crack: hand the attendance calculator a total of zero and it answers Infinity, or NaN — no exception, no warning, just a nonsense number that every comparison quietly returns false for. Class 17 starts by breaking that project on purpose.