Chapter 6 - Exceptions Flashcards
Runtime exceptions are also known as?
Runtime exceptions are also known as Unchecked exceptions.
Is a Runtime exception a subclass of RuntimeException?
Yes.
Is a Checked exception a subclass RuntimeException?
No. It is a subclass of Exception but not a subclass of RuntimeException.
What is the subclass of the Error type?
Subclass Error is the subclass of the Error type.
Are run time exceptions okay for a program to catch?
Yes, this applies to Runtime exception ans Checked exceptions.
Is a program requiered to handle or declared runtime exceptions?
No.
Is a program requiered to handle or declared checked exceptions?
Yes.
Is a program requiered to handle or declared Error?
No.
Do try statements require curly braces?
Yes. Try statements must have curly braces even if there is just one statement inside the code block.
Is catch neede after a try statement?
Yes, try must be always acompanied by a catch, otherwise the code will not compile.
Can finally blocks be used as part of try statements?
Yes. A finally block can only appear as part of a try statement.
Do finally blocks execute even if an exception in the try block does nos occur?
Yes. The finally block always executes whether or not an exception occurs in the try block.
Do a try statement must have catch and/or finally statements?
A try statement can have both: catch or finally. Having both is ok. No having any of those is a problem.
What will happen with a finally block if the System.exit method is called in the try or catch block?
If the System.exit method is called in a try or catch block, finally does not run.
Which type of exception is thrown When a superclass exception is caught before a subclass exception?
A compiler error about unreachable code occurs.