17. Making our own exceptions Flashcards
What is the superclass of Exception? Which other class shares this parent?
The superclass of Exception is Throwable. Error class also shares this parent.
What is special about RuntimeException?
RuntimeExceptions represent the kind of possible exceptions which programmers usually avoid in the first place, and thus Java relaxes the rule of having to catch the exception.
(E.g. when looping an array index over an array, the code would probably be written to use the correct values, and so avoid an ArrayIndexOutOfBoundsExpcetion exception)
How many constructors do our own exception classes typically have, and what are they?
Typically 4 constructor methods.
1) One with no method parameters.
2) One which takes a String for the message associated with the exception.
3) One which has both a message and a Throwable exception cause.
4) One which has only a cause.