Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
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
View Answer
A
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()
View Answer
C
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
View Answer
A
Q634: Which function would you use to remove all elements from a 'list' container in STL?
- A: clear()
- B: erase()
- C: remove()
- D: reset()
View Answer
A
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
View Answer
A
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
View Answer
A
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
View Answer
B
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
View Answer
C
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
View Answer
C
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
View Answer
C