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

Full screen (f)
exit full mode
Question
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
Use Space or
up arrow
down arrow
to flip the card.
Question
In the following statement: <strong>In the following statement:   What does T represent?</strong> 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 <div style=padding-top: 35px>
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
Question
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
Question
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
Question
When an error occurs, an exception is ________.

A)created
B)thrown
C)passed
D)ignored
E)None of these
Question
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
Question
In the following statement:<strong>In the following statement:  What does the word class indicate?</strong> 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 <div style=padding-top: 35px>
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
Question
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
Question
A(n)________ is a value or an object that signals an error.

A)destructor
B)template
C)throw
D)exception
E)None of these
Question
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
Question
In 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
Question
Catch blocks serve as ________.

A)exception handlers
B)wide receivers
C)temporary variables
D)permanent storage for trapped errors
E)None of these
Question
If 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
Question
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
Question
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
Question
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
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)use private members
D)duplicate code to handle multiple data types
E)None of these
Question
The beginning of a function template is marked by a ________.

A)return type
B)parameter list
C)template prefix
D)semicolon
E)None of these
Question
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
Question
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
Question
Using a function template requires less code than overloading a function.
Question
The try/catch/throw construct is able to handle only one type of exception in a try block.
Question
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
Question
A sequence container organizes data in a sequential fashion, similar to an array.
Question
There is no difference between declaring an object of an ordinary class and an object of a template class.
Question
If an exception is not caught, it is stored for later use.
Question
A program may not contain both a "regular" version of a function and a template version of the function.
Question
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
Question
The line containing a throw statement is known as the throw point.
Question
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
Question
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
Question
Types of iterators are ________.

A)input and output
B)forward and bidirectional
C)random-access
D)All of these
E)None of these
Question
When you declare an iterator to work with a container, the compiler automatically chooses the right type.
Question
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
Question
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
Question
The Standard Template Library (STL)contains templates for useful algorithms and data structures.
Question
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
Question
Function templates allow you to write a single function definition that works with many different data types.
Question
An associative container uses ________ to access elements rapidly.

A)data
B)functions
C)keys
D)complex sort algorithms
E)None of these
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/39
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 16: Exceptions, Templates, and the Standard Template Library Stl
1
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
type parameter
2
In the following statement: <strong>In the following statement:   What does T represent?</strong> 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
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 generic data type that is used in a function template
3
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
no memory
4
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
5
When an error occurs, an exception is ________.

A)created
B)thrown
C)passed
D)ignored
E)None of these
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
6
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
7
In the following statement:<strong>In the following statement:  What does the word class indicate?</strong> 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
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
8
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
9
A(n)________ is a value or an object that signals an error.

A)destructor
B)template
C)throw
D)exception
E)None of these
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
10
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
11
In 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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
12
Catch blocks serve as ________.

A)exception handlers
B)wide receivers
C)temporary variables
D)permanent storage for trapped errors
E)None of these
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
13
If 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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
14
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
15
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
16
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
17
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
18
The beginning of a function template is marked by a ________.

A)return type
B)parameter list
C)template prefix
D)semicolon
E)None of these
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
19
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
20
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
21
Using a function template requires less code than overloading a function.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
22
The try/catch/throw construct is able to handle only one type of exception in a try block.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
23
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
24
A sequence container organizes data in a sequential fashion, similar to an array.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
25
There is no difference between declaring an object of an ordinary class and an object of a template class.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
26
If an exception is not caught, it is stored for later use.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
27
A program may not contain both a "regular" version of a function and a template version of the function.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
28
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
29
The line containing a throw statement is known as the throw point.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
30
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
31
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
32
Types of iterators are ________.

A)input and output
B)forward and bidirectional
C)random-access
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
33
When you declare an iterator to work with a container, the compiler automatically chooses the right type.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
34
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
35
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
36
The Standard Template Library (STL)contains templates for useful algorithms and data structures.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
37
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
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
38
Function templates allow you to write a single function definition that works with many different data types.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
39
An associative container uses ________ to access elements rapidly.

A)data
B)functions
C)keys
D)complex sort algorithms
E)None of these
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 39 flashcards in this deck.