CSE2305 - Object-Oriented Software Engineering
Self Assesment Questions
For each question choose the single response which best answers the question, or which completes the statement most accurately.
Question 179: | An exception is: |
an unusual state that the program enters only rarely. |
an interrupt (or signal) received by the program from the operating system. |
an object which propagates up the call stack looking for an error handler. |
an object which propagates down the call stack looking for error conditions to handle. |
a "net" placed around a piece of code, to catch any errors. |
Question 180: | In C++ exceptions will only be caught when they are thrown by code: |
which is physically located in a try block. |
which has been called from a try block. |
which is physically located in a catch block. |
which has been called from a catch block. |
which has not yet executed. |
Question 181: | As an exception propagates it: |
destructs any locally-declared objects created in any function through which it passes. |
destructs any dynamically-allocated objects created in any function through which it passes. |
destructs any locally-declared or dynamically-allocated objects created in any function through which it passes. |
does not destruct any objects created in any function through which it passes. |
only destructs objects declared in the try block which eventually catches it. |
Question 182: | One advantage of using exceptions (as opposed to other error-handling techniques) is that: |
You don't have to specify how the code should handle the error, because the compiler takes care of that. |
You don't have to specify where the exception should be thrown, because the compiler takes care of that. |
You don't have to put error-handling code in every function, only those that detect or handle errors. |
You don't have to worry about your program terminating, since exceptions never cause a program to exit. |
Exceptions are built into the C++ language. |
Question 183: | If a try block has two or more associated catch blocks, which of them will be triggered by an exception? |
The first one whose catch parameter type matches that of the exception. |
The last one whose catch parameter type matches that of the exception. |
The one whose catch parameter type most closely matches that of the exception. |
Every one whose catch parameter type matches that of the exception. |
The only one whose catch parameter type matches that of the exception. If two or more catch blocks would match, the compiler flags an ambiguity. |
Last updated: October 1, 2005