Exceptions: Checked vs Unchecked, finally, throw vs throws
50 min · Beginner
An exception is an object that reports a problem while a program runs. Interviewers check whether you know the hierarchy, the checked vs unchecked split, throw vs throws, exactly when finally runs, and how to write clean handling instead of catching everything.
Topics in this lesson
- Recap: the Throwable hierarchy, Error vs Exception
- Checked vs unchecked; throw vs throws
- finally: when it runs and when it does not
- Custom exceptions and multi-catch
- Traps: broad catch, swallowing, catch order
Interview questions this lesson answers
- What is an exception?
- What is the exception hierarchy in Java?
- What is the difference between Error and Exception?
- What is the difference between checked and unchecked exceptions?
- What is the difference between throw and throws?
- Give examples of checked and unchecked exceptions.
- Why does Java have checked exceptions at all?
- Is NumberFormatException checked or unchecked?
- When does the finally block run?
- When does finally not run?
Sign in free to continue this lesson
Create a free account to read every lesson, practise with the exercises and keep track of your progress.