C++ Programming Multiple Choice Questions & Answers (MCQs) focuses on “Standard Template Library”.
Q 1. What is the Standard Template Library?
A. Set of C++ classes
B. Set of C++ template classes to provide common programming data structures and functions
C. Set of Template functions used for easy data structures implementation
D. Set of Template data structures only
Show Answer
Answer:-B. Set of C++ template classes to provide common programming data structures and functionsExplanation
STL expanded as Standard Template Library is set of C++ template classes to provide common programming data structures and functions.
Q 2. Pick the correct statement.
A. STL is a generalized library
B. Components of STL are parameterized
C. STL uses the concept of templates classes and functions to achieve generalized implementation
D. All of the mentioned
Show Answer
Answer:-D. All of the mentionedExplanation
STL is a generalized library and components of STL are parameterized. STL uses the concept of templates classes and function to achieve generalized implementation.
Q 3. How many components STL has?
A. 1
B. 2
C. 3
D. 4
Show Answer
Answer:-D. 4Explanation
STL has four components namely Algorithms, Containers, Functors and Iterators.Q 4. What are the containers?
A. Containers store objects and data
B. Containers stores all the algorithms
C. Containers contain overloaded functions
D. Containers contain set of Iterators
Show Answer
Answer:-A. Containers store objects and dataExplanation
Containers is a component of STL which stores objects and data.Q 5. In how many categories, containers are divided?
A. 1
B. 2
C. 3
D. 4
Show Answer
Answer:-D. 4Explanation
Containers are divided into 4 categories namely Sequence Containers, Associative Containers, Unordered Associative Containers and Container Adaptors.
Q 6. What are the Sequence Containers?
A. Containers that implements data structures which can be accessed sequentially
B. Containers that implements sorted data structures for fast search in O(logn)
C. Containers that implements unsorted(hashed) data structures for quick search in O(1)
D. Containers that implements data structures which can be accessed non-sequentially
Show Answer
Answer:-A. Containers that implements data structures which can be accessed sequentiallyExplanation
Sequence Containers is the subset of Containers that implements data structures which can be accessed sequentially.
Q 7. How many Sequence Containers are provided by C++?
A. 2
B. 3
C. 4
D. 5
Show Answer
Answer:-D. 5Explanation
C++ provides 5 types of Sequence Containers namely array, vector, deque, forward_list and list.
Q 8. What are the Associative Containers?
A. Containers that implements data structures which can be accessed sequentially
B. Containers that implements sorted data structures for fast search in O(logn)
C. Containers that implements unsorted(hashed) data structures for quick search in O(1)
D. Containers that implements data structures which can be accessed non-sequentially
Show Answer
Answer:-B. Containers that implements sorted data structures for fast search in O(logn)Explanation
Associative Containers is the subset of Containers that implements sorted data structures for fast search in O(logn).
Q 9. How many Associative Containers are provided by C++?
A. 2
B. 3
C. 4
D. 5
Show Answer
Answer:-C. 4Explanation
C++ provides 4 types of Associative Containers namely Set, Map, multiset and multimap.
Q 10. What are Unordered Associative Containers?
A. Containers that implements data structures which can be accessed sequentially
B. Containers that implements unsorted(hashed) data structures for quick search in O(1)
C. Containers that implements sorted data structures for fast search in O(logn)
D. Containers that implements data structures which can be accessed non-sequentially
Show Answer
Answer:-B. Containers that implements unsorted(hashed) data structures for quick search in O(1)Explanation
Unordered Associative Containers is the subset of Containers that implements unsorted(hashed) data structures for quick search in O(1) amortized O(n) Worst case complexity.
Q 11. What are Container Adaptors?
A. Containers that provide a different interface for sequential containers
B. Containers that implements sorted data structures for fast search in O(logn)
C. Containers that implements unsorted(hashed) data structures for quick search in O(1)
D. Containers that implements data structures which can be accessed sequentially
Show Answer
Answer:-A. Containers that provide a different interface for sequential containersExplanation
Container Adaptors is the subset of Containers that provides a different interface for sequential containers.
Q 12. How many Container Adaptors are provided by C++?
A. 2
B. 3
C. 4
D. 5
Show Answer
Answer:-B. 3Explanation
C++ provides 3 types of Container Adaptors namely Stack, Queue and Priority Queues.Q 13. What are Iterators?
A. Iterators are used to iterate over C-like arrays
B. Iterators are used to iterate over pointers
C. Iterators are used to iterate over functions
D. Iterators are used to point memory addresses of STL containers
Show Answer
Answer:-D. Iterators are used to point memory addresses of STL containersExplanation
In C++, Iterators are provided to iterate over the STL containers.
Q 14. How many types of Iterators are provided by C++?
A. 2
B. 3
C. 4
D. 5
Show Answer
Answer:-B. 3Explanation
There are five types of Iterators provided by C++ namely Input Iterators, Output Iterators, Forward Iterators, Bi-directional Iterators and Random-access Iterators.
Q 15. Which header file is used for Iterators?
A. <iter>
B. <algorithm>
C. <iterator>
D. <loopIter>
Leave a Reply