?? 4.txt
字號:
View Assessment Result: Multiple-Choice Quiz 4
Your performance was as follows:
1.
Which of the following statements regarding the design of the Standard Template Library (STL) in C++ is (are) true?
Each STL algorithm is usable with one specific container.
The STL does not use templates and instead relies on polymorphism.
(a) II only
(b) I and II
(c) None
(d) I only
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 2.1.1, subsection "The Standard Template Library," in the course notes.
--------------------------------------------------------------------------------
2.
The STL is heavily based on
(a) inheritance
(b) templates
(c) object oriented programming
(d) polymorphism
Correct answer is (b)
Your score on this question is: 10.00
Feedback:
See section 2.1.1 of the course notes.
--------------------------------------------------------------------------------
3.
For an STL iterator it, execution of the statement
++it;
does which of the following?
(a) Pre-increments the item to which the iterator points.
(b) Increase by 1 the size of the container pointed to by it.
(c) Post-increments the item to which the iterator points.
(d) Advances the iterator to the next item.
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 2.1.3 of the course notes.
--------------------------------------------------------------------------------
4.
The class vector in the C++ STL contains which of the following methods?
push_back
push_front
pop_front
(a) I, II, and III
(b) I and II only
(c) I only
(d) II and III only
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 2.2.3, subsection "Interface," in the course notes.
--------------------------------------------------------------------------------
5.
A typical implementation of a deque in the C++ STL minimizes the need to copy elements upon the frontal insertion of new items by
(a) reserving memory at the front of the deque's stored elements
(b) using a background thread to reallocate memory when necessary
(c) inserting the element at the end of the deque and maintaining a table of element positions
(d) inserting the element at the next available position in the deque and maintaining a table of element positions
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 2.2.3, subsection "Implementation," in the course notes.
--------------------------------------------------------------------------------
6.
If A is an STL vector, then the effect of executing the statement
A.push_back( x );
is to
(a) check whether the capacity of A is larger than the size of A, enlarges A if necessary, and append x to A
(b) append x to A, without checking the size and capacity of A
(c) append x to A if there is room, and otherwise overwrites the currently last element of A
(d) append x to A if and only if the size of A is less than capacity of A
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 2.1.2 of the course notes.
--------------------------------------------------------------------------------
7.
The size of an STL vector is defined to be the
(a) maximum number of elements that can be stored in the vector without resizing
(b) total of the sizes of the data members in the vector class
(c) number of bytes the vector occupies in memory
(d) number of elements currently stored in the vector
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 2.1.2 of the course notes.
--------------------------------------------------------------------------------
8.
If A is an STL vector, then the effect of executing the statement
A[i] = x;
is to
(a) write x to position i of the vector, without bounds checking
(b) create an iterator x pointing to position i in the array
(c) check array bounds, enlarge the vector if necessary, and then write x to position i
(d) check array bounds, and write x to position i if and only if i is in the proper range
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 2.1.2 of the course notes.
--------------------------------------------------------------------------------
9.
Consider the following C++ program segment, assuming that string is a class.
string str1("Hello, World");
str1[5] = 'Z';
The overloaded operator[] function invoked in the above program segment should have which of the following return types?
(a) char *
(b) char
(c) char &
(d) const char &
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See Chapter 2, pages 79–81, in the course textbook.
--------------------------------------------------------------------------------
10.
Which of the following statements is (are) true regarding strings in C++?
Strings in C++ are supported by the standard class string.
A constructor for the class string can accept a C-style string as an argument.
(a) I and II
(b) II only
(c) None
(d) I only
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 2.1, subsection "C-style Strings," in the course notes.
--------------------------------------------------------------------------------
Go to top of assessment.
Total score: 20.00
? Copyright 2004 iCarnegie, Inc. All rights reserved.
View Assessment Result: Multiple-Choice Quiz 4
Your performance was as follows:
1.
In the STL, common algorithms are instantiated for multiple types of container classes by using _____ to provide a uniform interface between the algorithms and containers.
(a) arrays
(b) iterators
(c) pointers
(d) virtual functions
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 2.1.1, subsection "Iterators," in the course notes.
--------------------------------------------------------------------------------
2.
Which of the following data structures is not a container implemented in the C++ Standard Template Library?
(a) List
(b) Vector
(c) Stack
(d) Hash table
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 2.1.1, subsection "STL Overview," in the course notes.
--------------------------------------------------------------------------------
3.
Execution of which of the following statements sets an STL iterator it so that it points to the first element of a container A?
(a) begin( A, it );
(b) A.begin( it );
(c) A.reset( it );
(d) it = A.begin();
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 2.1.3 of the course notes.
--------------------------------------------------------------------------------
4.
In the C++ Standard Template Library, vectors and deques differ in their interfaces for handling which of the following operations?
Insertion of an element at the front of the container
Insertion of an element at the end of the container
Removal of an element from the front of the container
(a) I and III only
(b) III only
(c) I only
(d) I and II only
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See Section 2.2.3, subsection "Interface," in the course notes.
--------------------------------------------------------------------------------
5.
Which of the following statements is (are) true of typical implementations of vectors and deques?
A vector's implementation uses one array, whereas a deque's implementation uses multiple arrays.
Insertions at the front of a deque tend to be more efficient than insertions at the front of a vector.
(a) I only
(b) None
(c) I and II
(d) II only
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 2.2.3, subsection "Implementation," in the course notes.
--------------------------------------------------------------------------------
6.
Consider the execution of the following.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -