Chapter 11 - Exceptions and Localization Flashcards
Supporting localization means you must immediately support specific languages. If false, why?
False. Localization support can be built early without implementing specific languages right away.
An exception is an event that alters program flow. If false, why?
True
All Java exceptions have “Exception” in their class name. If false, why?
False. Some exceptions, like Error and Throwable, do not include “Exception” in their name.
A checked exception must be declared or handled where it is thrown. If false, why?
True
Checked exceptions inherit Exception but not RuntimeException. If false, why?
True
Checked exceptions include all classes that inherit Throwable. If false, why?
False. Only classes that extend Exception but not Error or RuntimeException are checked exceptions.
The handle or declare rule applies to all exceptions. If false, why?
False. It only applies to checked exceptions, not unchecked exceptions like RuntimeException.
The throw keyword declares that a method might throw an exception. If false, why?
False. throw is used to actually throw an exception, while throws declares it in a method signature.
Checked exceptions require handling because they are usually anticipated. If false, why?
True
A catch block that catches Exception can handle IOException. If false, why?
True
A runtime exception is a subclass of RuntimeException and tends to be unexpected but not necessarily fatal.
True
An unchecked exception does not need to be declared or handled by the application code where it is thrown.
True
Errors indicate severe problems that a program should not attempt to recover from.
True
Throwable is the parent class of all exceptions, including both checked and unchecked exceptions.
True
The throw keyword is used to throw a new exception or rethrow an existing one inside a code block.
True
The throws keyword is used at the end of a method declaration to indicate what exceptions a method can throw.
True
An unchecked exception must be handled by the program.
No, handling is optional.)
Errors are checked exceptions that must be declared or handled.
(Errors are not checked exceptions and should not be handled.)
Throwable should always be caught directly in application code.
It is not recommended to catch Throwable directly.
A checked exception is a subclass of RuntimeException.
Checked exceptions are subclasses of Exception but not of RuntimeException.
The throw keyword is used at the method declaration to indicate possible exceptions.
No, that’s the throws keyword.
A program is required to handle or declare all exceptions.
Only checked exceptions must be handled or declared.)
Errors are typically recoverable in Java applications.
Errors represent serious issues that should not be recovered from.
RuntimeException is a checked exception.
No, it is an unchecked exception.