chapter 16 Flashcards

(39 cards)

1
Q

These are used to signal errors or unexpected events that occur while a program is running.
A) Virtual functions
B) Destructors
C) Exceptions
D) Templates
E) None of these

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The ________ starts with the key word try, and is followed by a block of code executing any statements that
might cause an exception to be thrown.
A) try block
B) try/catch class
C) try() function
D) catch() function
E) None of these

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When an error occurs, an exception is ________.
A) created
B) thrown
C) passed
D) ignored
E) None of these

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

An exception thrown from outside a try block ________.
A) will be caught outside the catch block
B) will be caught inside the catch block
C) will remain inside the throw block
D) will cause the program to abort execution
E) None of these

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

f an exception is thrown by a member function of a class object, then the class ________ is called.
A) constructor
B) destructor
C) catcher
D) handler
E) None of these

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

n a function template, the programmer substitutes ________ for ________.
A) parameters, data types
B) parameters, arguments
C) arguments, parameters
D) angle brackets, parentheses
E) None of these

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A(n) ________ is used in a function template to specify a generic data type.
A) dummy variable
B) exception
C) catch block
D) type parameter

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

he beginning of a function template is marked by a ________.
A) return type
B) parameter list
C) template prefix
D) semicolon
E) None of these

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In the following statement:
template < class T >
What does T represent?
A) the name of the function template
B) “T” stands for “Template”
C) a generic data type that is used in a function template
D) the int data type
E) None of these

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Class templates allow you to create one general version of a class without having to ________.
A) write any code
B) use member functions
C) use private members
D) duplicate code to handle multiple data types
E) None of these

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

n the following statement:
template <class>
What does the word class indicate?
A) class is a key word that is used to precede the type parameter T.
B) You are deriving a class from an existing class called T.
C) You are deriving a class called T from a class called template.
D) A class named T will automatically be created by the compiler.
E) None of these</class>

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Two types of container classes in the STL are:
A) sequence and associative
B) box and cylinder
C) array and struct
D) constant and literal
E) None of these

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A(n) ________ is like a pointer. It is used to access the individual data elements in a container.
A) element access operator
B) subscript indicator
C) global data finder
D) iterator
E) None of these

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The three sequence container objects provided by the STL are:
A) set, multiset, map
B) vector, deque, list
C) map, list, array
D) multimap, map, multilist
E) None of these

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A(n) ________ is a value or an object that signals an error.
A) destructor
B) template
C) throw
D) exception
E) None of these

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To handle an exception that has been thrown, a program must have a(n) ________.
A) throw() function
B) try/catch construct
C) fatal error
D) unrecoverable error
E) None of these

17
Q

The try block is immediately followed by one or more ________.
A) errors
B) error messages
C) catch blocks
D) throw blocks
E) None of these

18
Q

Catch blocks serve as ________.
A) exception handlers
B) wide receivers
C) temporary variables
D) permanent storage for trapped errors
E) None of these

19
Q

This is a “generic” function that can work with any data type.
A) function argument
B) function parameter
C) function template
D) member function
E) None of these

20
Q

How much memory is reserved for a function template?
A) four bytes
B) eight bytes
C) two bytes
D) no memory
E) None of these

21
Q

All type parameters defined in a function template must appear at least once in the ________.
A) function parameter list
B) preprocessor directives
C) function call
D) type.h file
E) None of these

22
Q

A function template’s prefix contains ________ enclosed in angled brackets.
A) one or more generic data types
B) the function definition
C) constant values
D) the function’s return type
E) None of these

23
Q

An actual instance of the function is created in memory when the compiler encounters ________.
A) the template prefix
B) a call to the template function
C) a try block
D) a catch block
E) None of these

24
Q

A function template prefix is placed before the function header. A class template prefix is placed ________.
A) following the public: access specification
B) following the private: access specification
C) before the class declaration
D) before the class constructor function header
E) None of these

25
The most important data structures in the STL are ________ and ________. A) arrays, structs B) lists, groups C) containers, iterators D) templates, prototypes E) None of these
C
26
A(n) ________ is a class that stores data and organizes it in some fashion. A) iterator B) container C) template D) box E) None of these
B
27
An associative container uses ________ to access elements rapidly. A) data B) functions C) keys D) complex sort algorithms E) None of these
C
28
Types of iterators are ________. A) input and output B) forward and bidirectional C) random-access D) All of these E) None of these
D
29
The algorithms provided by the STL are implemented as ________, and perform various operations on elements of containers. A) virtual functions B) function templates C) global variables D) private data members E) None of these
B
30
True/False: If an exception is not caught, it is stored for later use.
FALSE
31
True/False: The try/catch/throw construct is able to handle only one type of exception in a try block.
FALSE
32
True/False: A program may not contain both a "regular" version of a function and a template version of the function.
FALSE
33
True/False: There is no difference between declaring an object of an ordinary class and an object of a template class.
FALSE
34
True/False: The Standard Template Library (STL) contains templates for useful algorithms and data structures.
TRUE
35
rue/False: A sequence container organizes data in a sequential fashion, similar to an array.
TRUE
36
True/False: The line containing a throw statement is known as the throw point.
TRUE
37
True/False: Function templates allow you to write a single function definition that works with many different data types.
TRUE
38
rue/False: Using a function template requires less code than overloading a function.
TRUE
39
True/False: When you declare an iterator to work with a container, the compiler automatically chooses the right type.
TRUE