View Assessment Result: Multiple Choice Quiz 8



Your performance was as follows:

1.
Access to ranges of elements in an STL container is typically handled by

(a) references
(b) iterators
(c) suitable access member functions
(d) pointers

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (b) No Feedback



2.

Consider the following statement using the STL remove routine.

      remove( a, b, x );

What of the following accurately describes what the variables a and b represent?



(a) pointers
(b) iterators
(c) containers
(d) references

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (b) No Feedback



3.

Execution of the code fragment

    list<int>  A(10);

does which of the following?



(a) Creates a linked list of 10 ints, with each element initially containing random values.
(b) Creates 10 linked list of ints, all initially empty.
(c) Creates a linked list of 10 ints, with each element initially 0.
(d) Creates an empty linked list of ints, but reserves memory for 10 entries

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (c) No Feedback



4.

Consider the execution of the following.

    list<int>  A(10,20);

Which of the following accurately describes what is created?



(a) A linked list of size 10, each containing 10 arrays of ints of size 20
(b) A linked list of 10 ints, with each element initially 20
(c) a linked list of 10 linked lists, each containing 20 ints
(d) An array of size 20 of linked list, each containing 20 ints

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (b) No Feedback



5.

Consider the following code fragment.

      stack<int>  S;
      S.push(123);
      S.push(456);

Now consider the following statement.

   cout << S.pop() << endl;

Which of the following most accurately describes what goes wrong when that statement is executed?



(a) An execution error occurs because an STL stack has no member function pop().
(b) pop() does not return a value.
(c) An execution error occurs because pop() is a private member function.
(d) pop() requires an argument.

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (b) No Feedback



6.

For an STL iterator it, execution of the statement

    ++it;

does which of the following?



(a) Post-increments the item to which the iterator points.
(b) Pre-increments the item to which the iterator points.
(c)

Increase by 1 the size of the container pointed to by it.


(d) Advances the iterator to the next item.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (d) No Feedback



7.

For an STL iterator it and an STL container A, the expression

      it != A.end()

is used for which of the following purposes?



(a) To reset the iterator to the beginning of A
(b) To test whether the iterator is at the one-past-the-end position
(c) To test whether the iterator points to the last element of A
(d) To test whether the iterator points at some element of A

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (b) No Feedback



8.

Consider the following code fragment.

      li    st<int>::const_iterator  it;
      for(  it = L.begin(); it != L.end(); ++it )
      *it = 0;

What is syntactically wrong with this fragment?



(a) The use of the prefix increment operator on a const iterator.
(b) The traversal using a const iterator
(c) Nothing
(d) The assignment using a const iterator

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (d) No Feedback



9.
When using two iterators first and last to define a range of items in some container, which of the following is true concerning what they point to?

(a) first points at the first item, and last at the last element.
(b) It depends on the type of container.
(c) first points at a position one before the first item, and last at a position one past the last element.
(d) first points at the first item, and last at a position one past the last element.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (d) No Feedback



10.

Consider the following statement using the STL sort() routine.

      sort( A.begin(), A.end(), f );

Which of the following most accurately describes the result of executing this statement?



(a) Container A is sorted using sorting algorithm f.
(b) Container A is sorted using the function f for assignments.
(c) Container A is sorted by applying function f to its elements.
(d) Container A is sorted using the Boolean valued function f for comparisons.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.1.1 of the course notes.
   (d) No Feedback



Go to top of assessment.

Total score: 100.00