Deck 12: Handling Exceptions

Full screen (f)
exit full mode
Question
The general principle underlying good object-oriented error handling is that any called function should check for errors and handle an error if one is found.
Use Space or
up arrow
down arrow
to flip the card.
Question
Calling functions from within ____ blocks can be dangerous, especially if you call the function that caused the thrown exception in the first place.

A) try
B) throw
C) catch
D) exception
Question
Every function call is a(n) ____.

A) message
B) exception
C) abstraction
D) object
Question
A catch block ____ display, or to use in any way, what is thrown.

A) is required to
B) is not required to
C) must not
D) cannot
Question
The following dataEntry() function will not throw any exceptions: ____

A) int dataEntry() throw()
B) int dataEntry() throw(*)
C) int dataEntry() throw(void)
D) int dataEntry()
Question
Be careful when writing an exception specification using a(n) ____ because any type might eventually be instantiated.

A) virtual function
B) function template
C) void function
D) abstract function
Question
When you include multiple catch blocks in a program, ____ catch block that is able to accept a thrown object is the one that will execute.

A) every
B) any
C) the last
D) the first
Question
You create a default exception handler by creating a(n) ____ block with an ellipsis (…) as its parameter.

A) try
B) catch
C) throw
D) exit
Question
A general rule of ____ programming is that a function should be able to determine an error situation, but not necessarily take action on it.

A) logic
B) non-structured
C) modular
D) assembly
Question
When using the exit() function, it is traditional to use a non-zero argument to indicate a program exited normally, and a 0 argument to indicate an error.
Question
If you include an exception specification list with a function, and code a throw type that is not listed, the program will not compile.
Question
A function can make multiple throws.
Question
The exit() function requires a(n) ____ argument.

A) string
B) void
C) integer
D) double
Question
A(n) ____ resembles a return statement in a function, except that the execution of the program does not continue from where the function was called.

A) try
B) catch
C) throw
D) exit()
Question
To handle a thrown object, you include one or more ____ blocks in your program immediately following a try block.

A) exit
B) catch
C) throw
D) exit
Question
In Visual C++, ____ is interpreted the same as throw(...) .

A) throw(exception e)
B) throw()
C) throw(void)
D) throw( type )
Question
In ANSI C++, if a function throws an error whose type was not listed in its exception specification, then it will produce a run-time error called a(n) ____ exception, and abort the program.

A) default
B) unspecified
C) virtual
D) unexpected
Question
If you use a default catch block, it ____.

A) must be the first catch block listed after a try
B) must be the last catch block listed after a try
C) can be located anywhere after a try
D) can be located anywhere before a try
Question
If you want a catch block to execute, it must catch the correct type of argument thrown from a try block.
Question
You throw an exception by using the keyword throw followed by ____ object.

A) an exception
B) a catch
C) a string
D) any C++
Question
If a function does not catch a thrown exception, then a function that calls that function can still catch the exception. This process is called ____.

A) unwinding the stack
B) specifying exceptions
C) exception handling
D) throwing an exception
Question
Describe one disadvantage of using the default catch block.
Question
Describe the general principle underlying good object-oriented error handling.
Question
If a function throws an exception, but the function call has not been placed in a(n) ____________________ block, then the program terminates.
Question
You should be careful when writing an exception specification using a(n) ____________________ because any type might eventually be instantiated.
Question
When would you want to use a default exception handler?
Question
Which constants can you use as arguments to the exit() function?
Question
____________________ are errors that occur during execution of object-oriented programs, and are so-named because, presumably, they are not usual occurrences.
Question
When a function throws an exception, the function is no longer ____.

A) object-oriented
B) a "black box"
C) virtual
D) void
Question
To use the set_new_handler() function, you should insert ____ at the top of your program file.

A) #include
B) #include
C) #include
D) #include
Question
You ____________________ a function; if it throw s an exception, you catch and handle it.
Question
Why would you want to write an exception specification?
Question
As with a try block, a catch block must contain ____________________, even if they surround only one statement.
Question
When any object is thrown with a throw statement, what conditions does a subsequent catch block have to meet to have a usable match?
Question
____ an exception is the act of explicitly passing a caught exception along to a higher-level catch block.

A) Throwing
B) Unwinding
C) Rethrowing
D) Stacking
Question
Explain what the following statement means: "When creating a class to hold an exception, be careful not to create an instantiation that results in the same problem as the original error did".
Question
When an object-oriented program detects an error within a function, the function should send an error object to the calling function, or ____________________ an exception.
Question
In object-oriented terminology, what is a message?
Question
Visual C++ departs from the ____ standard in its implementation of exception specifications.

A) ANSI
B) IEEE
C) gcc
D) ISO
Question
The ____ function was created to solve the universal problem of insufficient memory.

A) exit()
B) set_new_handler()
C) atexit()
D) not_enough_memory()
Question
Match between columns
declaration of a function's possible throw types
catch block
declaration of a function's possible throw types
try block
declaration of a function's possible throw types
exception specification
declaration of a function's possible throw types
exception
declaration of a function's possible throw types
exception class
declaration of a function's possible throw types
exception handling
declaration of a function's possible throw types
exit() function
declaration of a function's possible throw types
default exception handler
declaration of a function's possible throw types
message
Question
Match between columns
part of the C++ Standard library
catch block
part of the C++ Standard library
try block
part of the C++ Standard library
exception specification
part of the C++ Standard library
exception
part of the C++ Standard library
exception class
part of the C++ Standard library
exception handling
part of the C++ Standard library
exit() function
part of the C++ Standard library
default exception handler
part of the C++ Standard library
message
Question
When should you use exception handling?
Question
Match between columns
catches any type of object not previously caught
catch block
catches any type of object not previously caught
try block
catches any type of object not previously caught
exception specification
catches any type of object not previously caught
exception
catches any type of object not previously caught
exception class
catches any type of object not previously caught
exception handling
catches any type of object not previously caught
exit() function
catches any type of object not previously caught
default exception handler
catches any type of object not previously caught
message
Question
Match between columns
contains statements that execute when an exception is thrown
catch block
contains statements that execute when an exception is thrown
try block
contains statements that execute when an exception is thrown
exception specification
contains statements that execute when an exception is thrown
exception
contains statements that execute when an exception is thrown
exception class
contains statements that execute when an exception is thrown
exception handling
contains statements that execute when an exception is thrown
exit() function
contains statements that execute when an exception is thrown
default exception handler
contains statements that execute when an exception is thrown
message
Question
Match between columns
one or more statements that the program attempts to execute, but which might result in thrown exceptions
catch block
one or more statements that the program attempts to execute, but which might result in thrown exceptions
try block
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception specification
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception class
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception handling
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exit() function
one or more statements that the program attempts to execute, but which might result in thrown exceptions
default exception handler
one or more statements that the program attempts to execute, but which might result in thrown exceptions
message
Question
Match between columns
passed object that contains information
catch block
passed object that contains information
try block
passed object that contains information
exception specification
passed object that contains information
exception
passed object that contains information
exception class
passed object that contains information
exception handling
passed object that contains information
exit() function
passed object that contains information
default exception handler
passed object that contains information
message
Question
Match between columns
set of object-oriented techniques used to manage execution-time errors
catch block
set of object-oriented techniques used to manage execution-time errors
try block
set of object-oriented techniques used to manage execution-time errors
exception specification
set of object-oriented techniques used to manage execution-time errors
exception
set of object-oriented techniques used to manage execution-time errors
exception class
set of object-oriented techniques used to manage execution-time errors
exception handling
set of object-oriented techniques used to manage execution-time errors
exit() function
set of object-oriented techniques used to manage execution-time errors
default exception handler
set of object-oriented techniques used to manage execution-time errors
message
Question
Why was the set_new_handler() function introduced in C++?
Question
Match between columns
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
catch block
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
try block
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception specification
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception class
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception handling
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exit() function
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
default exception handler
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
message
Question
Match between columns
forces a program to end
catch block
forces a program to end
try block
forces a program to end
exception specification
forces a program to end
exception
forces a program to end
exception class
forces a program to end
exception handling
forces a program to end
exit() function
forces a program to end
default exception handler
forces a program to end
message
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/51
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 12: Handling Exceptions
1
The general principle underlying good object-oriented error handling is that any called function should check for errors and handle an error if one is found.
False
2
Calling functions from within ____ blocks can be dangerous, especially if you call the function that caused the thrown exception in the first place.

A) try
B) throw
C) catch
D) exception
C
3
Every function call is a(n) ____.

A) message
B) exception
C) abstraction
D) object
A
4
A catch block ____ display, or to use in any way, what is thrown.

A) is required to
B) is not required to
C) must not
D) cannot
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
5
The following dataEntry() function will not throw any exceptions: ____

A) int dataEntry() throw()
B) int dataEntry() throw(*)
C) int dataEntry() throw(void)
D) int dataEntry()
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
6
Be careful when writing an exception specification using a(n) ____ because any type might eventually be instantiated.

A) virtual function
B) function template
C) void function
D) abstract function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
7
When you include multiple catch blocks in a program, ____ catch block that is able to accept a thrown object is the one that will execute.

A) every
B) any
C) the last
D) the first
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
8
You create a default exception handler by creating a(n) ____ block with an ellipsis (…) as its parameter.

A) try
B) catch
C) throw
D) exit
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
9
A general rule of ____ programming is that a function should be able to determine an error situation, but not necessarily take action on it.

A) logic
B) non-structured
C) modular
D) assembly
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
10
When using the exit() function, it is traditional to use a non-zero argument to indicate a program exited normally, and a 0 argument to indicate an error.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
11
If you include an exception specification list with a function, and code a throw type that is not listed, the program will not compile.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
12
A function can make multiple throws.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
13
The exit() function requires a(n) ____ argument.

A) string
B) void
C) integer
D) double
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
14
A(n) ____ resembles a return statement in a function, except that the execution of the program does not continue from where the function was called.

A) try
B) catch
C) throw
D) exit()
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
15
To handle a thrown object, you include one or more ____ blocks in your program immediately following a try block.

A) exit
B) catch
C) throw
D) exit
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
16
In Visual C++, ____ is interpreted the same as throw(...) .

A) throw(exception e)
B) throw()
C) throw(void)
D) throw( type )
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
17
In ANSI C++, if a function throws an error whose type was not listed in its exception specification, then it will produce a run-time error called a(n) ____ exception, and abort the program.

A) default
B) unspecified
C) virtual
D) unexpected
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
18
If you use a default catch block, it ____.

A) must be the first catch block listed after a try
B) must be the last catch block listed after a try
C) can be located anywhere after a try
D) can be located anywhere before a try
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
19
If you want a catch block to execute, it must catch the correct type of argument thrown from a try block.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
20
You throw an exception by using the keyword throw followed by ____ object.

A) an exception
B) a catch
C) a string
D) any C++
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
21
If a function does not catch a thrown exception, then a function that calls that function can still catch the exception. This process is called ____.

A) unwinding the stack
B) specifying exceptions
C) exception handling
D) throwing an exception
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
22
Describe one disadvantage of using the default catch block.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
23
Describe the general principle underlying good object-oriented error handling.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
24
If a function throws an exception, but the function call has not been placed in a(n) ____________________ block, then the program terminates.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
25
You should be careful when writing an exception specification using a(n) ____________________ because any type might eventually be instantiated.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
26
When would you want to use a default exception handler?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
27
Which constants can you use as arguments to the exit() function?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
28
____________________ are errors that occur during execution of object-oriented programs, and are so-named because, presumably, they are not usual occurrences.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
29
When a function throws an exception, the function is no longer ____.

A) object-oriented
B) a "black box"
C) virtual
D) void
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
30
To use the set_new_handler() function, you should insert ____ at the top of your program file.

A) #include
B) #include
C) #include
D) #include
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
31
You ____________________ a function; if it throw s an exception, you catch and handle it.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
32
Why would you want to write an exception specification?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
33
As with a try block, a catch block must contain ____________________, even if they surround only one statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
34
When any object is thrown with a throw statement, what conditions does a subsequent catch block have to meet to have a usable match?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
35
____ an exception is the act of explicitly passing a caught exception along to a higher-level catch block.

A) Throwing
B) Unwinding
C) Rethrowing
D) Stacking
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
36
Explain what the following statement means: "When creating a class to hold an exception, be careful not to create an instantiation that results in the same problem as the original error did".
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
37
When an object-oriented program detects an error within a function, the function should send an error object to the calling function, or ____________________ an exception.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
38
In object-oriented terminology, what is a message?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
39
Visual C++ departs from the ____ standard in its implementation of exception specifications.

A) ANSI
B) IEEE
C) gcc
D) ISO
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
40
The ____ function was created to solve the universal problem of insufficient memory.

A) exit()
B) set_new_handler()
C) atexit()
D) not_enough_memory()
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
declaration of a function's possible throw types
catch block
declaration of a function's possible throw types
try block
declaration of a function's possible throw types
exception specification
declaration of a function's possible throw types
exception
declaration of a function's possible throw types
exception class
declaration of a function's possible throw types
exception handling
declaration of a function's possible throw types
exit() function
declaration of a function's possible throw types
default exception handler
declaration of a function's possible throw types
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
42
Match between columns
part of the C++ Standard library
catch block
part of the C++ Standard library
try block
part of the C++ Standard library
exception specification
part of the C++ Standard library
exception
part of the C++ Standard library
exception class
part of the C++ Standard library
exception handling
part of the C++ Standard library
exit() function
part of the C++ Standard library
default exception handler
part of the C++ Standard library
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
43
When should you use exception handling?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
44
Match between columns
catches any type of object not previously caught
catch block
catches any type of object not previously caught
try block
catches any type of object not previously caught
exception specification
catches any type of object not previously caught
exception
catches any type of object not previously caught
exception class
catches any type of object not previously caught
exception handling
catches any type of object not previously caught
exit() function
catches any type of object not previously caught
default exception handler
catches any type of object not previously caught
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
45
Match between columns
contains statements that execute when an exception is thrown
catch block
contains statements that execute when an exception is thrown
try block
contains statements that execute when an exception is thrown
exception specification
contains statements that execute when an exception is thrown
exception
contains statements that execute when an exception is thrown
exception class
contains statements that execute when an exception is thrown
exception handling
contains statements that execute when an exception is thrown
exit() function
contains statements that execute when an exception is thrown
default exception handler
contains statements that execute when an exception is thrown
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
46
Match between columns
one or more statements that the program attempts to execute, but which might result in thrown exceptions
catch block
one or more statements that the program attempts to execute, but which might result in thrown exceptions
try block
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception specification
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception class
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exception handling
one or more statements that the program attempts to execute, but which might result in thrown exceptions
exit() function
one or more statements that the program attempts to execute, but which might result in thrown exceptions
default exception handler
one or more statements that the program attempts to execute, but which might result in thrown exceptions
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
47
Match between columns
passed object that contains information
catch block
passed object that contains information
try block
passed object that contains information
exception specification
passed object that contains information
exception
passed object that contains information
exception class
passed object that contains information
exception handling
passed object that contains information
exit() function
passed object that contains information
default exception handler
passed object that contains information
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
48
Match between columns
set of object-oriented techniques used to manage execution-time errors
catch block
set of object-oriented techniques used to manage execution-time errors
try block
set of object-oriented techniques used to manage execution-time errors
exception specification
set of object-oriented techniques used to manage execution-time errors
exception
set of object-oriented techniques used to manage execution-time errors
exception class
set of object-oriented techniques used to manage execution-time errors
exception handling
set of object-oriented techniques used to manage execution-time errors
exit() function
set of object-oriented techniques used to manage execution-time errors
default exception handler
set of object-oriented techniques used to manage execution-time errors
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
49
Why was the set_new_handler() function introduced in C++?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
50
Match between columns
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
catch block
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
try block
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception specification
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception class
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exception handling
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
exit() function
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
default exception handler
object that contains information that is passed from the place where a problem occurs to another place that will handle the problem
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
51
Match between columns
forces a program to end
catch block
forces a program to end
try block
forces a program to end
exception specification
forces a program to end
exception
forces a program to end
exception class
forces a program to end
exception handling
forces a program to end
exit() function
forces a program to end
default exception handler
forces a program to end
message
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 51 flashcards in this deck.