Quiz on Exceptions and Errors

This is a practice quiz. The results are not recorded anywhere and do not affect your grade. The questions on this quiz might not appear in any quiz or test that does count toward your grade.

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.

1. From which problems is it possible for a program to recover?

a.    Errors
b.    Exceptions
c.    Both errors and exceptions
d.    Neither.

Correct Answer Is:

2. Both class Error and class Exception are children of this parent:

a.    Throwable
b.    Catchable
c.    Runable
d.    Problem

Correct Answer Is:

3. Is a program required to catch all exceptions that might happen?

a.    No. You can write a program to catch just the exceptions you want.
b.    No. But if a program catches one type of exception it must catch all other types as well.
c.    Yes. If a program is not written to catch all exceptions it will not compile.
d.    Yes. A program can not do I/O unless it catches all exceptions.

Correct Answer Is:

4. What type of exception is thrown by parseInt() if it gets illegal data?

a.    ArithmeticException
b.    RunTimeException
c.    NumberFormatException
d.    NumberError

Correct Answer Is:

5. Which statement is FALSE about the try{} block?

a.    Some of the statements in a try{} block will never throw an exception.
b.    The statements in a try{} block may throw several types of exception.
c.    The try{} block can not contain loops or branches.
d.    The try{} block must appear before the catch{} blocks.

Correct Answer Is:

6. Which statement is FALSE about catch{} blocks?

a.    There can be several catch{} blocks in a try/catch structure.
b.    The catch{} block for a child exception class must PRECEED that of a parent execption class.
c.    The catch{} block for a child exception class must FOLLOW that of a parent execption class.
d.    If there is no catch{} block there must be a finally{} block.

Correct Answer Is:

7. Which of the following lists exception types from MOST specific to LEAST specific?

a.    Error, Exception
b.    Exception, RunTimeException
c.    Throwable, RunTimeException
d.    ArithmeticException, RunTimeException

Correct Answer Is:

8. What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?

a.    This is not legal, so the program will not compile.
b.    The method throws the exception to its caller, exactly if there were no try{} block.
c.    The program halts immediately.
d.    The program ignores the exception.

Correct Answer Is:

9. How many finally{} blocks may there be in a try/catch structure?

a.    There must always be one, following the last catch{} block.
b.    There can be zero or one immediately after each catch{} block.
c.    There can be zero or one, following the last catch{} block.
d.    There can be any number, following the last catch{} block.

Correct Answer Is:

10. When is a finally{} block executed?

a.    Only when an unhandled exception is thrown in a try{} block.
b.    Only when any exception is thrown in a try{} block.
c.    Always after execution has left a try{} block, no matter for what reason.
d.    Always just as a method is about to finish.

Correct Answer Is:

The number you got right:       Percent Correct:       Letter Grade:   

Click here (If you have just returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the "shift key" while clicking on reload to clear the old answers.)