Deck 18: Exception Handling
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/29
Play
Full screen (f)
Deck 18: Exception Handling
1
A function declared thus: void func(argument_list)throw();should throw no exception of any type.
True
2
Compilers will check code in functions against exception specifications.
False
3
A function uses an exception specification that includes only int,but an exception of type double is thrown.A catch block is provided that catches a double,so things proceed properly.
False
4
The default action of unexpected()can be changed.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
5
When an event occurs that cannot be managed locally,an exception may be thrown.Throwing the exception object transfers control and information gleaned locally to some calling program unit that manages the event,or the program terminates.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
6
An exception is signaled or raised with the keyword catch followed by an exception object that may be of any C++ type.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
7
Mentioning a base class B in an exception specification includes a class D objects,where D is derived from B,in the exception specification.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
8
A circumstance in C++ where an exception is thrown must be an error.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
9
The exception specification for a function has no effect on an exception that is caught within the function.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
10
If an exception is thrown in a function,say,f(),but not handled there,the exception is propagated to the function that called f().
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
11
In C++ an exception object must be derived from the exception class defined in the standard library.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
12
In C++,an exception object can be a user-defined type or any type that is built-into C++ language.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
13
Statements that cause an exception must be part of a try block.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
14
A function does not have an exception specification at all,so exceptions are prohibited.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
15
The context in which the throwing of an exception is detected is the try block.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
16
The context in which an exception is handled (or managed)is the throw block.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
17
An uncaught exception in C++ is ignored.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
18
A program can continue to run after an exception has been thrown and caught.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
19
Suppose an exception of type E is thrown in a function but not listed in the exception specification,and is not caught in the function.The exception will be caught in a calling function that has a catch block that declares an exception of that type.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
20
In type matching to select a catch block,only exact matches work.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
21
Describe the circumstances that the unexpected()function will be called.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
22
How can you write a catch block that will catch all exceptions that have been thrown but not yet caught?
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
23
Write a definition for an exception class,E,that contains an error number and a string type error name.Include a constructor that creates an E object and initializes both members.Provide accessors for both the message and error number.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
24
What is the purpose of exception handling?
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
25
The situations where exceptions are used put the try block with the throw statement followed by the catch block all in one function.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
26
Explain how the mechanism for deciding which catch block catches an exception is like the mechanism for deciding which function definition is used when an overloaded function is called.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
27
A function that satisfies its preconditions but cannot fulfill its postconditions should throw an exception.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
28
Write just a catch block with a catch block parameter type that will catch all exceptions that are yet uncaught.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
29
When an exception is thrown,the function finishes its execution,its value is returned,then control is transferred to the catch block.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck