Concept
Exceptions
Always use for files, streams, connections. Extend for checked, for unchecked.
Where it fits
Packages: Core Java (pkg1core)
Learn
Existing chapters for this concept.
- Exceptions
Always use for files, streams, connections. Extend for checked, for unchecked.
Open lesson →
See it in code
Existing Java examples.
- core 18 Exceptions Demo
- Throwable -> Error (don't catch) and Exception. - Checked exceptions (extend Exception) must be declared/handled. - Unchecked (extend RuntimeException) are…
Open example →
Prepare
Existing interview questions.
- Checked vs unchecked exceptions?
Checked must be declared/handled; unchecked (RuntimeException) need not be.
Open question → - Can overriding method throw broader checked exceptions?
Clear naming, small methods, immutability, proper exceptions, tests, and idiomatic APIs.
Open question → - InterruptedException meaning?
Prefer immutability and high-level concurrency utilities over low-level locks.
Open question → - Custom exception design?
Extend for checked, for unchecked; meaningful messages; optional error codes.
Open question → - Should you catch `Exception` or `Throwable`?
Avoid broad catch in application code; catch specific types.
Open question → - Assertions vs exceptions?
for internal invariants (disabled by default); exceptions for contract violations callers should handle.
Open question → - Best practices for exception messages?
Actionable, include context (ids, operation), no secrets.
Open question → - Generic exception?
Use bounded wildcards on input params (PECS), exact types on outputs.
Open question →
Java versions
- Helpful NullPointerExceptions
Helpful NullPointerExceptions. A NullPointerException can name which part of an expression was null. The feature is on by default.
Open version note →