This set of C++ Programming Multiple Choice Questions & Answers (MCQs) focuses on “Standard Template Library”.
1. What is the Standard Template Library?
a) Set of C++ template classes to provide common programming data structures and functions
b) Set of C++ classes
c) Set of Template functions used for easy data structures implementation
d) Set of Template data structures only
View Answer
Explanation: STL expanded as Standard Template Library is set of C++ template classes to provide common programming data structures and functions.
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
View Answer
Explanation: STL is a generalized library and components of STL are parameterized. STL uses the concept of templates classes and function to achieve generalized implementation.
3. How many components STL has?
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: STL has four components namely Algorithms, Containers, Functors and Iterators.
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
View Answer
Explanation: Containers is a component of STL which stores objects and data.
5. In how many categories, containers are divided?
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: Containers are divided into 4 categories namely Sequence Containers, Associative Containers, Unordered Associative Containers and Container Adaptors.
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
View Answer
Explanation: Sequence Containers is the subset of Containers that implements data structures which can be accessed sequentially.
7. How many Sequence Containers are provided by C++?
a) 2
b) 3
c) 4
d) 5
View Answer
Explanation: C++ provides 5 types of Sequence Containers namely array, vector, deque, forward_list and list.
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
View Answer
Explanation: Associative Containers is the subset of Containers that implements sorted data structures for fast search in O(logn).
9. How many Associative Containers are provided by C++?
a) 2
b) 3
c) 4
d) 5
View Answer
Explanation: C++ provides 4 types of Associative Containers namely Set, Map, multiset and multimap.
10. What are Unordered 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
View Answer
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.
11. What are Container Adaptors?
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 provide a different interface for sequential containers
View Answer
Explanation: Container Adaptors is the subset of Containers that provides a different interface for sequential containers.
12. How many Container Adaptors are provided by C++?
a) 2
b) 3
c) 4
d) 5
View Answer
Explanation: C++ provides 3 types of Container Adaptors namely Stack, Queue and Priority Queues.
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 point memory addresses of STL containers
d) Iterators are used to iterate over functions
View Answer
Explanation: In C++, Iterators are provided to iterate over the STL containers.
14. How many types of Iterators are provided by C++?
a) 2
b) 3
c) 4
d) 5
View Answer
Explanation: There are five types of Iterators provided by C++ namely Input Iterators, Output Iterators, Forward Iterators, Bi-directional Iterators and Random-access Iterators.
15. Which header file is used for Iterators?
a) <iterator>
b) <algorithm>
c) <iter>
d) <loopIter>
View Answer
Explanation: Iterators are present inside the <iterator> header file so this header file is needed to use Iterators.
Sanfoundry Global Education & Learning Series – C++ Programming Language.
To practice all areas of C++ language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Computer Science Internship
- Check C++ Books
- Practice Computer Science MCQs
- Check Programming Books
- Check Computer Science Books