revised: 10/05/03


Quiz on Exceptions

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.


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

A.    Throwable

B.    Catchable

C.    Runable

D.    Problem


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.


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

A.    ArithmeticException

B.    RunTimeException

C.    InputMismatchException

D.    NumberError


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.


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.


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


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.


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.


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.


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


Click here If you have 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 to clear the old answers.