Test Series - cpp

Test Number 65/102

Q: What is the lifetime of the element in container?
A. Whole program
B. Outside the block
C. Everywhere
D. Only on that container
Solution: A Container “owns” its elements: the lifetime of an element stored in a container cannot exceed that of the Container itself.
Q: Which are not full container classes in c++?
A. Sequence container
B. Associative container
C. Container adaptor
D. iterative container
Solution: Container adaptors are not full container classes, but classes that provide a specific interface relying on an object of one of the container classes such as deque or list to handle the elements.
Q: What do all STL containers define?
A. Iterator types
B. Begin methods
C. End methods
D. All of the mentioned
Solution: All the STL containers define the iterator types for that container, e.g., iterator and const_iterator, e.g., vector::iterator and the begin/end methods for that container, e.g., begin() and end().
Q: What do we return if we use simple array on a internal container?
A. Methods
B. Pointers
C. Objects
D. Values
Solution: Pointers are legal iterators, so if your internal container is a simple C array, then all you need to do is return the pointers.
Q: What is mandatory for designing a new container?
A. Classes
B. Iterators
C. Container
D. Variables
Solution: Iterators are used to increase the generality of an algorithm. Otherwise, we need to define the algorithm for each types.
Q: What are the design requirements for building a container from the sratch?
A. Container interface requirements
B. Allocator interface requirements
C. Iterator requirements
D. All of the mentioned
Solution: These are the design specific requirements for building a container from the scratch.
Q: How many iterators are needed for the defining a new container?
A. 1
B. 2
C. 3
D. 4
Solution: There are three main iterators needed for designing a container. They are const iterator, Reverse iterator and Iterator traits.
Q: What is the use of the allocator interface in the user-defined container?
A. Storage management
B. Memory management
C. Storage & Memory management
D. Iterator management
Solution: Storage management is the use of the allocator interface in the user-defined container.
Q: How many types of container classes are there in c++?
A. 1
B. 2
C. 3
D. As many as possible
Solution: There are two type of container classes in c++. They are value containers and reference containers.
Q: What is the name of the container which contains group of multiple objects?
A. Heterogeneous container
B. Homogeneous container
C. Both Homogeneous & Heterogeneous container
D. Sequence container
Solution: Heterogeneous container is the name of the container which contains group of multiple objects.

You Have Score    /10