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.
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
- Part-H openerThe slate arc across Classes 17–20, and the campus food-ordering crash-log spine that runs through all four.
- What an exception actually isA runtime error signal — and why Java refuses to just crash silently.
- Why exceptions, not error codesThe same failure a C function signals with
-1and a globalerrno, Java signals by throwing. - The exception hierarchy
Throwable→Error/Exception→RuntimeException, drawn out in full. - Checked vs uncheckedCompiler-enforced versus the
RuntimeExceptionfamily — the distinction the exam keeps asking about. - PYQ · P2·Q4 · 2 marksDifferentiate checked and unchecked exceptions, with examples.
- The five you will actually meet
NullPointerException,ArrayIndexOutOfBoundsException,ClassCastException,NumberFormatException,ArithmeticException. - Worked example — all five, for realOne small program triggers each in turn, with the genuine terminal message for every one.
- Activity 1 · classify the crash logFive real crash lines from the food-ordering app — name the exception in each.
- 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.