CS52 Chapter 16 – Quiz With Complete Solutions
The following function does not throw any unhandled exceptions void f1( )
throw ( ); - ANSWER TRUE
Functions that might throw an exception must have a throw list. - ANSWER
FALSE
Functions may potentially throw at most one exception. - ANSWER FALSE
If a function throws an exception, it must be caught inside that function. -
ANSWER FALSE
It is legal to have a catch block with no parameter. - ANSWER TRUE
In a try block, the throw statement is always executed. - ANSWER FALSE
The catch block is a function. - ANSWER FALSE
The braces are not necessary on a try block. - ANSWER FALSE
The throw statement passes a value to the catch block. - ANSWER TRUE
The catch block is the group of statements that handle an exception. -
ANSWER TRUE
Which of the following is not a valid reason for using exception handling? -
ANSWER throw and catch can be used like gotos
, The block of code that checks if an unusual situation or error occurs is
called - ANSWER the try block
The block of code that handles an exception is called - ANSWER the catch
block
When an unusual situation or error occurs, then the ________ statement is
executed. - ANSWER throw
A catch block that expects an integer argument will catch - ANSWER all
integer exceptions
When a throw statement is executed, - ANSWER execution of the try block
stops
The parameter in the catch statement - ANSWER identifies what type of
exceptions are caught
The throw statement is enclosed in - ANSWER a try block
A throw statement can throw
a. an integer exception
b. a float exception
c. a bool exception
d. an exception of any data type
e. all of the above
f. none of the above - ANSWER e. all of the above
The following catch statement
catch(...) - ANSWER catches all exceptions
The following class definition
class MyError
{}; - ANSWER has only a default constructor
The following function does not throw any unhandled exceptions void f1( )
throw ( ); - ANSWER TRUE
Functions that might throw an exception must have a throw list. - ANSWER
FALSE
Functions may potentially throw at most one exception. - ANSWER FALSE
If a function throws an exception, it must be caught inside that function. -
ANSWER FALSE
It is legal to have a catch block with no parameter. - ANSWER TRUE
In a try block, the throw statement is always executed. - ANSWER FALSE
The catch block is a function. - ANSWER FALSE
The braces are not necessary on a try block. - ANSWER FALSE
The throw statement passes a value to the catch block. - ANSWER TRUE
The catch block is the group of statements that handle an exception. -
ANSWER TRUE
Which of the following is not a valid reason for using exception handling? -
ANSWER throw and catch can be used like gotos
, The block of code that checks if an unusual situation or error occurs is
called - ANSWER the try block
The block of code that handles an exception is called - ANSWER the catch
block
When an unusual situation or error occurs, then the ________ statement is
executed. - ANSWER throw
A catch block that expects an integer argument will catch - ANSWER all
integer exceptions
When a throw statement is executed, - ANSWER execution of the try block
stops
The parameter in the catch statement - ANSWER identifies what type of
exceptions are caught
The throw statement is enclosed in - ANSWER a try block
A throw statement can throw
a. an integer exception
b. a float exception
c. a bool exception
d. an exception of any data type
e. all of the above
f. none of the above - ANSWER e. all of the above
The following catch statement
catch(...) - ANSWER catches all exceptions
The following class definition
class MyError
{}; - ANSWER has only a default constructor