Test Series - cpp

Test Number 83/102

Q: What kind of iteration does forward_list provide in C++?
A. Uni-directional
B. Bi-directional
C. Multi-directional
D. Bi-directional & Multi-directional
Solution: The forward_list uses singly linked list hence it is uni-directional. In the forward_list, the container provides insertion and removal at anywhere in the program.
Q: What does the size of the vector refers to in c++?
A. Size of vector
B. Type of vector
C. Number of elements
D. Name of vector
Solution: In vectors, by size we mean the number of elements in that vector array.
Q: Subsequent elements are moved in terms of _____ when an element in inserted in vector?
A. Assignment Operator
B. Copy constructor
C. Both assignment operator and copy constructor
D. destructor
Solution: The vector maintains a certain order of its elements, so that when a new element is inserted at the beginning or in the middle of the vector, Subsequent elements are moved backwards in terms of their assignment operator or copy constructor.
Q: What is the use of adapter in STL in c++?
A. To provide interface
B. To manipulate the data
C. To extract the data
D. To delete the data
Solution: Adapters are data types from STL that adapt a container to provide specific interface.
Q: Which is used to iterate over container?
A. Associated iterator type
B. Data type of objects
C. Return type of variables
D. Name of the variables
Solution: Associated iterator type is used to iterate over container.
Q: What does the function objects implement?
A. operator
B. operator()
C. operand
D. operand<>
Solution: Function objects are objects specifically designed to be used with a syntax similar to that of functions.
Q: What are the two advantage of function objects than the function call?
A. It contains a state
B. It is a type
C. It contains a state & It is a type
D. It contains a prototype
Solution: A function object can contain state. The second is that a function object is a type and therefore can be used as a template parameter.
Q: Which header is need to be used with function objects?
A. 
B. 
C. 
D. 
Solution:  header is need to be used with function objects.
Q: Which are instances of a class with member function operator() when it is defined?
A. function objects
B. member
C. methods
D. iterators
Solution: Function objects are instances of a class with member function operator() defined. This member function allows the object to be used with the same syntax as a regular function call.
Q: How many parameters does a operator() in a function object shoud take?
A. 1
B. 2
C. 3
D. 4
Solution: In the case of binary function objects, this operator() member function will take two parameters.

You Have Score    /10