Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Chapter: 41
Q621:
What does STL stand for in C++?
A. Standard Template Library
B. Standard Type Library
C. Static Template Library
D. Structured Template Library
Correct Answer:
A
Chapter: 41
Q622:
Which of the following is NOT a key component of STL?
A. Containers
B. Iterators
C. Algorithms
D. Functions
Correct Answer:
B
Chapter: 41
Q623:
What type of container is a 'vector' in STL?
A. Sequence Container
B. Associative Container
C. Container Adapter
D. Utility Container
Correct Answer:
A
Chapter: 41
Q624:
Which STL container allows rapid insertions and deletions at both ends?
A. Deque
B. List
C. Vector
D. Stack
Correct Answer:
B
Chapter: 41
Q625:
In STL, which container allows duplicate elements?
A. Set
B. Map
C. Multi-Set
D. Queue
Correct Answer:
C
Chapter: 41
Q626:
What function is used to add an element to the back of a 'vector' in STL?
A. push_back
B. push_front
C. insert
D. remove
Correct Answer:
A
Chapter: 41
Q627:
Which of the following containers is used for a last-in, first-out (LIFO) data structure?
A. Stack
B. Queue
C. Priority Queue
D. Deque
Correct Answer:
A
Chapter: 41
Q628:
Which STL container does NOT allow duplicate keys?
A. Map
B. Multi-Map
C. Set
D. Multi-Set
Correct Answer:
A
Chapter: 41
Q629:
What is the primary function of a 'map' in STL?
A. To store key-value pairs with unique keys
B. To store elements in a sorted order
C. To store elements with duplicate keys
D. To provide fast retrieval by index
Correct Answer:
A
Chapter: 41
Q630:
In the STL example provided, which function returns the size of a 'set' before insertions?
A. size
B. empty
C. max_size
D. iterator
Correct Answer:
B
Chapter: 41
Q631:
In which STL container is the 'insert' function used to add elements in a sorted order?
A. Map
B. Set
C. Multi-Set
D. Queue
Correct Answer:
A
Chapter: 41
Q632:
Which iterator function returns an iterator object that refers to the last element of a container?
A. begin()
B. end()
C. rbegin()
D. rend()
Correct Answer:
C
Chapter: 41
Q633:
Which STL container would you use if you need to ensure elements are unique and sorted?
A. Set
B. Multi-Map
C. Map
D. Multi-Set
Correct Answer:
A
Chapter: 41
Q634:
Which function would you use to remove all elements from a 'list' container in STL?
A. clear()
B. erase()
C. remove()
D. reset()
Correct Answer:
A
Chapter: 41
Q635:
What output is expected after inserting elements into a 'set' in STL?
A. No duplicates allowed
B. All elements are stored in order
C. Elements are stored in a queue
D. Elements are stored in a stack
Correct Answer:
A
Chapter: 42
Q636:
Which iterator category can only move in forward direction one element at a time?
A. Input Iterators
B. Output Iterators
C. Forward Iterators
D. Random-access Iterators
Correct Answer:
A
Chapter: 42
Q637:
What is the primary difference between Bidirectional Iterators and Forward Iterators?
A. Bidirectional Iterators support multi-pass algorithms, Forward Iterators do not
B. Bidirectional Iterators can move in backward direction, Forward Iterators cannot
C. Bidirectional Iterators can directly access any element, Forward Iterators cannot
D. Bidirectional Iterators can only move in forward direction, Forward Iterators can move in both directions
Correct Answer:
B
Chapter: 42
Q638:
Random-access Iterators provide all capabilities of which other iterator categories?
A. Input and Output Iterators
B. Output and Forward Iterators
C. Forward and Bidirectional Iterators
D. Bidirectional and Output Iterators
Correct Answer:
C
Chapter: 42
Q639:
Which iterator type is used with containers like `vector` and `deque`?
A. Input Iterators
B. Output Iterators
C. Random-access Iterators
D. Bidirectional Iterators
Correct Answer:
C
Chapter: 42
Q640:
Which iterator type cannot be used with container adapters like stack, queue, and priority_queue?
A. Random-access Iterators
B. Bidirectional Iterators
C. Input Iterators
D. Output Iterators
Correct Answer:
C