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) iterators
(b) pointers
(c) suitable access member functions
(d) references

Correct answer is (a)

Your score on this question is: 10.00

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



2.

Consider the execution of the following.

   list<int>  A(10);

Which of the following accurately describes what is created?



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

Correct answer is (c)

Your score on this question is: 0.00

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



3.

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) An array of size 20 of linked list, each containing 20 ints
(c) a linked list of 10 linked lists, each containing 20 ints
(d) A linked list of 10 ints, with each element initially 20

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



4.

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 pop() is a private member function.
(b) pop() requires an argument.
(c) An execution error occurs because an STL stack has no member function pop().
(d) pop() does not return a value.

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



5.

Execution of the code fragment

    stack<int,vector<int> >  S;

does which of the following?



(a) Creates a stack of ints, based on an integer vector
(b) Creates a vector of integer stacks
(c) Creates a stack of integer vectors
(d) Produces an execution error

Correct answer is (a)

Your score on this question is: 10.00

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



6.

For an STL iterator it, execution of the statement

    ++it;

does which of the following?



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

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


Correct answer is (a)

Your score on this question is: 0.00

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



7.

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 traversal using a const iterator
(b) The use of the prefix increment operator on 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



8.

The STL contains a general purpose search function:

      find( first, last, x );

What does find return if it finds item x?



(a) A pointer pointing to x
(b) An iterator pointing to x
(c) A reference to x
(d) The Boolean value true

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



9.

The STL contains a general purpose search function:

      find( first, last, x );

What does find return if it fails to find item x?



(a) The Boolean value false
(b) A NULL pointer
(c) An iterator equal to begin
(d) An iterator equal to last

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: 80.00