Standard Template Library (STL) – MCQs July 22, 2025 by u930973931_answers 30 Score: 0 Attempted: 0/30 Subscribe 1. : What does STL in C++ stand for? (A) Standard Transfer Library (B) Standard Template Library (C) Structured Type Library (D) System Template Library 2. : Which of the following is not a type of STL container? (A) Sequence (B) Associative (C) Adapter (D) Stream 3. : What is the main advantage of using STL? (A) Code reusability (B) Portability (C) Performance optimization (D) All of the above 4. : Which container stores elements in a linear fashion? (A) map (B) set (C) vector (D) multimap 5. : Which container allows duplicate elements? (A) set (B) multiset (C) map (D) unordered_set 6. : Which associative container stores key-value pairs? (A) vector (B) list (C) map (D) queue 7. : Which of the following is not an STL algorithm? (A) sort (B) reverse (C) add (D) find 8. : Which container adapter gives LIFO behavior? (A) queue (B) deque (C) stack (D) vector 9. : Which header file includes STL components? 10. : Which of the following is not a sequence container? (A) vector (B) deque (C) list (D) map 11. : What does the iterator do in STL? (A) Stores data (B) Performs computation (C) Traverses elements (D) Removes elements 12. : Which of these containers maintains a sorted order by default? (A) unordered_map (B) set (C) list (D) stack 13. : Which adapter container uses two ends for insertion and deletion? (A) stack (B) queue (C) priority_queue (D) deque 14. : What does begin() function return in STL containers? (A) End iterator (B) Null pointer (C) Iterator to first element (D) Iterator to last element 15. : What does end() function return? (A) Iterator past the last element (B) Null (C) Last element (D) First element 16. : Which container uses key-value pairs and does not allow duplicate keys? (A) multimap (B) map (C) multiset (D) vector 17. : Which container allows random access to elements? (A) list (B) map (C) vector (D) set 18. : What type of container is priority_queue? (A) Sequence (B) Adapter (C) Associative (D) Hybrid 19. : Which algorithm is used to arrange elements in ascending order? (A) sort (B) reverse (C) rotate (D) remove 20. : Which function removes all elements from a container? (A) remove() (B) erase() (C) clear() (D) delete() 21. : Which container does not allow duplicate values? (A) multiset (B) vector (C) set (D) multimap 22. : What is the use of count() function in STL? (A) To count elements in a container (B) To count specific elements (C) To check if container is empty (D) To assign a value 23. : What is the time complexity of accessing an element in vector by index? (A) O(log n) (B) O(n) (C) O(1) (D) O(n log n) 24. : Which container is best for fast search, insert, and delete operations? (A) list (B) vector (C) set (D) stack 25. : Which algorithm finds the maximum element? (A) max_element (B) max (C) maximum (D) top 26. : Which container supports insertion/removal at both ends efficiently? (A) deque (B) vector (C) list (D) map 27. : What does unique() do in STL? (A) Finds unique elements (B) Removes consecutive duplicates (C) Sorts elements (D) Removes all duplicates 28. : In STL, what is emplace_back() used for? (A) Inserts at the front (B) Removes from back (C) Constructs in place at the end (D) Sorts the container 29. : What type of iterator is used with set? (A) Random access iterator (B) Bidirectional iterator (C) Input iterator (D) Output iterator 30. : Which container allows reverse iteration? (A) vector (B) set (C) list (D) All of the above