midterm 2 Flashcards
t/f A new node cannot become the first node in the list.
f
t/f The Standard Template Library (STL) contains templates for useful algorithms and data
structures
t
t/f A sequential container organizes data in a sequential fashion, similar to an array or linked
list.
t
t/f Inserting an item into a linked list requires that all the items past the point of the insertion
be shifted to make room for the new item.
f
t/f At most one catch block may be attached to a single try block.
f
t/f The values stored in the value portion of a node of a linked list can be simple data types,
structures, objects of classes, or any other data type.
t
t/f When you create a vector it is unnecessary to specify how many elements it will hold
because it will expand in size as you add new values to it.
t
t/f If an exception is not caught, it is stored for later use.
f
t/f Deleting an entire linked list requires a call to the delete operator for each node in the list.
t
t/f 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.
t
t/f There is no difference between defining an object of an ordinary class and an object of a template class.
f
t/f When you create a linked list, you must know in advance how many nodes the list will
contain.
f
t/f Nodes in a linked list are stored in contiguous memory.
f
t/f The STL vector and list classes are examples of sequential containers.
t
t/f The following statement adds a new element to the department vector at index 25:
department.push_back(25);
f
t/f An exception is a condition that can be caused by a syntax error in the program.
f
t/f Using a function template often requires writing less code than overloading a function.
t
\_\_\_\_\_\_\_\_ to a base class may be assigned the address of a derived class object. A) Static members B) Access specifiers C) Pointers D) Private members E) None of the above
c
Which of the following operations do constant iterators not have?
A) Prefix operator* to make available the container element for use as l-value or r-value.
B) Overloaded binary operator+ to add an int value to the iterator to move the place the
iterator points forward by the argument number of elements.
C) Overloaded unary operator++ to move the place the iterator points forward by one
element.
D) Overloaded unary operator– to move the place the iterator points backward by one
element.
E) Overloaded operator== and operator!= to determine whether two iterators point to the
same element.
a
Linked lists of items are commonly implemented by
A) using a class template to represent list items.
B) using a function to compute the link to the next item.
C) using an array to hold list items.
D) using a structure containing an item and a pointer to the structure type.
E) None of the above
d
In the statement template , what does the word class indicate? A) A class called T will automatically be created by the compiler. B) You are deriving a class from an existing class called T. C) class is a keyword that indicates that T is a type parameter. D) You are deriving a class called T from a class called template. E) None of the above
c
The bad_alloc exception is thrown
A) by the new operator.
B) only when the program contains a catch block.
C) when program code encounters a bad memory location.
D) when you forget to free memory with the delete operator.
E) None of the above
a
Types of iterators are A) reverse. B) random-access. C) forward and bidirectional. D) All of the above E) None of the above
d
A(n) \_\_\_\_\_\_\_\_ is like a pointer. It is used to access the individual data elements in a container. A) subscript indicator B) element access operator C) iterator D) global data finder E) None of the above
c