Chapter 6: Exceptions Flashcards
What is true of all checked exceptions?
They are not subclasses of RuntimeException
T or F. Error is a subclass of Exception
False. It is a subclass of Throwable with Exception as a sibling
What is a checked exception?
An exception that must be handled or declared in order for the code to compile
T or F. A try block doesn’t require a catch block
True. A try block requires at least on catch or finally block
T or F. A try block can have multiple finally blocks
False
What happens when multiple exceptions are thrown?
Only the last one matters and is passed on
What kind of exception is ArithmeticException?
Runtime
What kind of exception is ArrayIndexOutOfBoundsException?
Runtime
What kind of exception is ClassCastException?
Runtime
What kind of exception is IllegalArgumentException?
Runtime
What kind of exception is NullPointerException?
Runtime
What kind of exception is NumberFormatException?
Runtime
What kind of exception is FileNotFoundException?
Checked
What kind of exception is IOException?
Checked
When must the caller handle an exception?
When a method declares that it throws a checked exception