Chapter 17: Making our own Exceptions Flashcards

1
Q

What are checked an unchecked exceptions

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe the exception hierarchy

A

Throwable
/ \
Error Exception
/ \
Runtime IO
/
Index out of bounds
/ \
Array index out of bounds | String index out of bounds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why can we make our own exceptions?

A

Exceptions are in an inheritance hierarchy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do we make our own exceptions?

A
  1. Choose a standard class closest to what we want. Exception if checked, runtime if unchecked.
  2. Make a subclass of it
  3. Write four constructor methods:
    no method parameters
    one that takes a string
    one with string and throwable
    one with only throwable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly