Test Series - cpp

Test Number 62/102

Q: How many sets of requirements are need in designing a container?
A. 1
B. 2
C. 3
D. 4
Solution: There are three sets of requirements. They are container interface requirements, Allocator interface requirements and iterator requirements.
Q: Which interface in the container is required for storage management?
A. Memory management
B. Allocator interface
C. Memory interface
D. Storage interface
Solution: Allocator interface in the container is required for storage management.
Q: Which is present in the basic interface of the allocator interface?
A. Set of typedefs
B. A pair of allocation functions
C. allocate()
D. All of the mentioned
Solution: The basic interface of an allocator class consists of a set of typedefs, a pair of allocation functions, allocate() and deallocate() and a pair of construction/destruction members, construct() and destroy().
Q: Which is used for manually writing lookup table?
A. std:map
B. std:lookup
C. std:find
D. std:lock
Solution: Lookup table means storing values in a table with unique keys for each value so that can be checked in future easily. So for such lookup tables maps are used in C++.
Q: How can the member functions in the container be accessed?
A. Iterator
B. Indirect
C. Both Iterator & Indirect
D. Vector
Solution: The container manages the storage space for its elements and provides member functions to access them, either directly or through iterators which reference objects with similar properties to pointers.
Q: Which of the following type does the container should define?
A. Iterator type
B. Vector type
C. Storage type
D. Memory type
Solution: Every container must define an iterator type. Iterators allow algorithms to iterate over the container’s contents.
Q: Which are the parameters for the content of the buffer?
A. start
B. finish
C. both start & finish
D. pause
Solution: The contents of the buffer are initialized using the values from the iterator range supplied to the constructor by the start and finish parameters.
Q: What do vectors represent?
A. Static arrays
B. Dynamic arrays
C. Stack
D. Queue
Solution: Vectors are sequence containers representing arrays that can change in size.
Q: In which type of storage location are the vector members stored?
A. Contiguous storage locations
B. Non-contiguous storage locations
C. Contiguous & Non-contiguous storage locations
D. Memory storage locations
Solution: Vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements
Q: How many vector container properties are there in c++?
A. 1
B. 2
C. 3
D. 4
Solution: There are three container properties in c++. They are sequence, Dynamic array and allocator-aware.

You Have Score    /10