Chapter 17: Making our own Exceptions Flashcards
What are checked an unchecked exceptions
Checked- we must have a catch clause or declare throws. Checked at compile time
Unchecked- The rule is relaxed e.g. run time exceptions and similar
Describe the exception hierarchy
Throwable
/ \
Error Exception
/ \
Runtime IO
/
Index out of bounds
/ \
Array index out of bounds | String index out of bounds
Why can we make our own exceptions?
Exceptions are in an inheritance hierarchy
How do we make our own exceptions?
- Choose a standard class closest to what we want. Exception if checked, runtime if unchecked.
- Make a subclass of it
- Write four constructor methods:
no method parameters
one that takes a string
one with string and throwable
one with only throwable