Deck 16: Exceptions, Templates, and the Standard Template Library STL

Full screen (f)
exit full mode
Question
An actual instance of a template function is created in memory when the compiler encounters

A)a call to the template function.
B)a catch block.
C)a try block.
D)the template prefix.
E)None of the above
Use Space or
up arrow
down arrow
to flip the card.
Question
When an error occurs, an exception is

A)passed.
B)ignored.
C)created.
D)thrown.
E)None of the above
Question
A _ is a "generic" function that can work with different data types.

A)function argument
B)function template
C)function parameter
D)member function
E)None of the above
Question
In the statement template , what does T represent?

A)T stands for "template"
B)The name of the function template
C)A generic data type that is used in a function template
D)The "int" data type
E)None of the above
Question
How much memory is reserved for a function template?

A)four bytes
B)no memory
C)eight bytes
D)two bytes
E)None of the above
Question
The bad_alloc exception is thrown

A)when program code encounters a bad memory location.
B)only when the program contains a catch block.
C)by the new operator.
D)when you forget to free memory with the delete operator.
E)None of the above
Question
A(n)is like a pointer. It is used to access the individual data elements in a container.

A)subscript indicator
B)iterator
C)element access operator
D)global data finder
E)None of the above
Question
An associative container uses to access values stored in it.

A)complex sort algorithms
B)functions
C)keys
D)data
E)None of the above
Question
In a function template, the programmer substitutes for .

A)arguments, parameters
B)parameters, arguments
C)angle brackets, parentheses
D)parameters, data types
E)None of the above
Question
The algorithms provided by the STL are implemented as , and perform various operations on elements of containers.

A)global variables
B)virtual functions
C)private data members
D)function templates
E)None of the above
Question
In the statement template , what does the word class indicate?

A)You are deriving a class called T from a class called template.
B)class is a keyword that indicates that T is a type parameter.
C)A class called T will automatically be created by the compiler.
D)You are deriving a class from an existing class called T.
E)None of the above
Question
All type parameters defined in a function template must appear at least once in the

A)function parameter list.
B)type.h file.
C)preprocessor directives.
D)function call.
E)None of the above
Question
Class templates allow you to create one general version of a class without having to

A)write any code.
B)use member functions.
C)duplicate code to handle multiple data types.
D)use private members.
E)None of the above
Question
The most important data structures in the STL are _ _ and .

A)templates, prototypes
B)lists, groups
C)containers, iterators
D)arrays, structs
E)None of the above
Question
A function template's prefix contains _ in angled brackets.

A)the function's return type
B)constant values
C)the function definition
D)one or more generic data types
E)None of the above
Question
are used to signal errors or unexpected events that occur while a program is running.

A)Templates
B)Virtual functions
C)Exceptions
D)Destructors
E)None of the above
Question
Types of iterators are

A)random- access.
B)input and output.
C)forward and bidirectional.
D)All of the above
E)None of the above
Question
A(n)_ is a class that stores data and organizes it in some fashion.

A)template
B)container
C)iterator
D)box
E)None of the above
Question
A catch block serves as

A)a temporary variable.
B)an indicator of program correctness.
C)an exception handler.
D)permanent storage for trapped errors.
E)None of the above
Question
A try block must immediately be followed by one or more

A)catch blocks.
B)error parameters.
C)error messages.
D)throw blocks.
E)None of the above
Question
A program may not contain a "regular" version of a function and a template version of the function at the same time.
Question
The three sequential container objects currently provided by the STL are

A)vector, deque, list.
B)set, multiset, map.
C)map, list, array.
D)multimap, map, multilist.
E)None of the above
Question
Non- template functions have a slight advantage in speed over template functions.
Question
The line containing a throw statement is known as the throw point.
Question
A thrown exception for which there is no matching catch block will cause the execution of the program to abort.
Question
There is no difference between defining an object of an ordinary class and an object of a template class.
Question
At most one catch block may be attached to a single try block.
Question
An exception is a condition that can be caused by a syntax error in the program.
Question
A sequential container organizes data in a sequential fashion, similar to an array or linked list.
Question
Iterators are objects that are similar to pointers.
Question
Function templates allow you to write a single function definition that works with many different data types.
Question
Two types of container classes in the STL are

A)box and cylinder.
B)sequential and associative.
C)constant and literal.
D)array and struct.
E)None of the above
Question
The Standard Template Library (STL)contains templates for useful algorithms and data structures.
Question
The STL vector and list classes are examples of sequential containers.
Question
If an exception is not caught, it is stored for later use.
Question
The beginning of a function template is marked by a

A)template prefix.
B)parameter list.
C)return type.
D)semicolon.
E)None of the above
Question
The C++ mechanism for exception handling encloses code that might throw an exception in a try block and puts exception handling code in catch blocks attached to the try block.
Question
To catch an exception, a program must

A)have a try/catch construct.
B)have a throw()function.
C)first experience a fatal error.
D)first experience an unrecoverable error.
E)None of the above
Question
Using a function template often requires writing less code than overloading a function.
Question
A(n)is used in a function template to specify a generic data type.

A)dummy variable
B)catch block
C)exception
D)type parameter
E)None of the above
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 16: Exceptions, Templates, and the Standard Template Library STL
1
An actual instance of a template function is created in memory when the compiler encounters

A)a call to the template function.
B)a catch block.
C)a try block.
D)the template prefix.
E)None of the above
A
2
When an error occurs, an exception is

A)passed.
B)ignored.
C)created.
D)thrown.
E)None of the above
D
3
A _ is a "generic" function that can work with different data types.

A)function argument
B)function template
C)function parameter
D)member function
E)None of the above
B
4
In the statement template , what does T represent?

A)T stands for "template"
B)The name of the function template
C)A generic data type that is used in a function template
D)The "int" data type
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
How much memory is reserved for a function template?

A)four bytes
B)no memory
C)eight bytes
D)two bytes
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
The bad_alloc exception is thrown

A)when program code encounters a bad memory location.
B)only when the program contains a catch block.
C)by the new operator.
D)when you forget to free memory with the delete operator.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
A(n)is like a pointer. It is used to access the individual data elements in a container.

A)subscript indicator
B)iterator
C)element access operator
D)global data finder
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
An associative container uses to access values stored in it.

A)complex sort algorithms
B)functions
C)keys
D)data
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
In a function template, the programmer substitutes for .

A)arguments, parameters
B)parameters, arguments
C)angle brackets, parentheses
D)parameters, data types
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
The algorithms provided by the STL are implemented as , and perform various operations on elements of containers.

A)global variables
B)virtual functions
C)private data members
D)function templates
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
In the statement template , what does the word class indicate?

A)You are deriving a class called T from a class called template.
B)class is a keyword that indicates that T is a type parameter.
C)A class called T will automatically be created by the compiler.
D)You are deriving a class from an existing class called T.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
All type parameters defined in a function template must appear at least once in the

A)function parameter list.
B)type.h file.
C)preprocessor directives.
D)function call.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
Class templates allow you to create one general version of a class without having to

A)write any code.
B)use member functions.
C)duplicate code to handle multiple data types.
D)use private members.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
The most important data structures in the STL are _ _ and .

A)templates, prototypes
B)lists, groups
C)containers, iterators
D)arrays, structs
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
A function template's prefix contains _ in angled brackets.

A)the function's return type
B)constant values
C)the function definition
D)one or more generic data types
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
are used to signal errors or unexpected events that occur while a program is running.

A)Templates
B)Virtual functions
C)Exceptions
D)Destructors
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
Types of iterators are

A)random- access.
B)input and output.
C)forward and bidirectional.
D)All of the above
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
A(n)_ is a class that stores data and organizes it in some fashion.

A)template
B)container
C)iterator
D)box
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
A catch block serves as

A)a temporary variable.
B)an indicator of program correctness.
C)an exception handler.
D)permanent storage for trapped errors.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
A try block must immediately be followed by one or more

A)catch blocks.
B)error parameters.
C)error messages.
D)throw blocks.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
A program may not contain a "regular" version of a function and a template version of the function at the same time.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
The three sequential container objects currently provided by the STL are

A)vector, deque, list.
B)set, multiset, map.
C)map, list, array.
D)multimap, map, multilist.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
Non- template functions have a slight advantage in speed over template functions.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
The line containing a throw statement is known as the throw point.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
A thrown exception for which there is no matching catch block will cause the execution of the program to abort.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
There is no difference between defining an object of an ordinary class and an object of a template class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
At most one catch block may be attached to a single try block.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
An exception is a condition that can be caused by a syntax error in the program.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
A sequential container organizes data in a sequential fashion, similar to an array or linked list.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
Iterators are objects that are similar to pointers.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
Function templates allow you to write a single function definition that works with many different data types.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
Two types of container classes in the STL are

A)box and cylinder.
B)sequential and associative.
C)constant and literal.
D)array and struct.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
The Standard Template Library (STL)contains templates for useful algorithms and data structures.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
The STL vector and list classes are examples of sequential containers.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
If an exception is not caught, it is stored for later use.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
The beginning of a function template is marked by a

A)template prefix.
B)parameter list.
C)return type.
D)semicolon.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
The C++ mechanism for exception handling encloses code that might throw an exception in a try block and puts exception handling code in catch blocks attached to the try block.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
To catch an exception, a program must

A)have a try/catch construct.
B)have a throw()function.
C)first experience a fatal error.
D)first experience an unrecoverable error.
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
Using a function template often requires writing less code than overloading a function.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
A(n)is used in a function template to specify a generic data type.

A)dummy variable
B)catch block
C)exception
D)type parameter
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.