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

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.

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 0.
(b) Creates a linked list of 10 ints, with each element initially containing random values.
(c) Creates an empty linked list of ints, but reserves memory for 10 entries
(d) Creates 10 linked list of ints, all initially empty.

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



3.

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



4.

Execution of the code fragment

    stack<int,vector<int> >  S;

does which of the following?



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

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,list<int> >  S;

does which of the following?



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

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



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)

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


(d) Pre-increments the item to which the iterator points.

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



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 test whether the iterator points to the last element of A
(b) To test whether the iterator is at the one-past-the-end position
(c) To test whether the iterator points at some element of A
(d) To reset the iterator to the beginning of A

Correct answer is (b)

Your score on this question is: 0.00

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



8.
What is the difference between a bidirectional iterator (BDI) and a random access iterator (RAI)?

(a) They only differ with respect to efficiency, but they support the same operations.
(b) The RAI can jump in arbitrary increments and decrements; a BDI can only move in increments/decrements of one.
(c) A RAI supports post-increment, but a BDI does not.
(d) A BDI cannot be moved backwards, but a RAI can.

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 finds item x?



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

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



10.

The STL contains a general purpose search function:

      find( first, last, x );

What search method does find use?



(a) Linear search
(b) Binary search
(c) It depends on the type of container.
(d) It depends on whether the data are sorted.

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



Go to top of assessment.

Total score: 90.00