Home »
Aptitude Questions and Answers »
C++ Aptitude Questions and Answers
C++ Containers & Iterators Aptitude Questions and Answers
C++ Containers & Iterators Aptitude: This section contains C++ Containers & Iterators Aptitude Questions and Answers with explanations.
Submitted by Nidhi, on February 20, 2021
1) There are the following statements that are given below, which of them are correct about containers in C++?
- Containers are objects that are used to hold the same type of data.
- We can implement different data structures using containers in C++.
- Both of the above
- None of the above
Options:
- A
- B
- C
- D
Correct Answer - 3
C
Explanation:
Both A and B statements are correct about containers in C++.
2) Which of the following are correct types of containers in C++?
- Associative containers
- Sequence containers
- Derived containers
- Logical containers
Options:
- A and B
- A and C
- A, B, and C
- A, B, C, and D
Correct Answer - 3
A, B, and C
Explanation:
Options A, B, and C are correct types of containers in C++.
3) Which of the following are correct sequence containers used in C++?
- vector
- set
- stack
- list
Options:
- A and B
- A and C
- A and D
- A, B, C, and D
Correct Answer - 3
A and D
Explanation:
The vector and list are sequence containers used in C++.
4) Which of the following are correct associative containers used in C++?
- deque
- set
- map
- queue
Options:
- A and B
- B and C
- A and D
- A, B, C, and D
Correct Answer - 2
B and C
Explanation:
The set and map are correct associative containers used in C++.
5) The stack is a sequence container?
- Yes
- No
Correct Answer - 2
No
Explanation:
The stack is a derived container.
6) There are the following statements that are given below, which of them are correct about iterators in C++?
- Iterators are just like pointers that are used to access elements from containers.
- We can move from one element to another element sequentially.
- Iterators are predefined structures.
- All of the above
Options:
- A and B
- A and C
- A, B, and C
- A, B, C, and D
Correct Answer - 1
A and B
Explanation:
Statements A and B are correct about iterators in C++.
7) Which of the following function are used by iterators in C++?
- begin()
- end()
- random()
- movebyindex()
Options:
- A and B
- A and C
- A, B, and C
- A, B, C, and D
Correct Answer - 1
A and B
Explanation:
The begin() and end() functions are used by iterators in C++.
8) Which of the following are correct types of iterators used in C++?
- Input iterator
- Output iterator
- Forward iterator
- Random Access iterator
Options:
- A and B
- A and C
- A, B, and C
- A, B, C, and D
Correct Answer - 4
A, B, C, and D
Explanation:
All given options are the correct types of iterators used in C++.
9) Which of the following statements are correct about output iterators?
- Output iterators are used to modify the value of elements in a container.
- Output iterators are write-only iterators. We cannot read the value of containers.
- Output iterators are one-way iterators.
- None of the above
Options:
- A and B
- A and C
- A, B, and C
- D
Correct Answer - 3
A, B, and C
Explanation:
Statements A, B, and C are correct about output iterators.
10) Which of the following are two-way iterators?
- Input iterator
- Output iterator
- Bidirectional iterator
- Random access iterator
Options:
- A and B
- A and C
- B and C
- C and D
Correct Answer - 4
C and D
Explanation:
The bidirectional and random access iterators are two-way iterators.
11) Which of the following are correct operations are supported by iterators in C++?
- Read operations
- Write operations
- Increment operations
- Comparison operations
Options:
- A and B
- A and C
- A, B, and C
- A, B, C, and D
Correct Answer - 4
A, B, C, and D
Explanation:
All given operations are supported by iterators.
12) Which of the following algorithms are used for containers in C++?
- Sorting algorithms
- Relational algorithms
- Mutating algorithms
- Exception based algorithms
Options:
- A and B
- A and C
- A, B, and C
- A, B, C, and D
Correct Answer - 3
A, B, and C
Explanation:
Options A, B, and C are correct algorithms used for containers in C++.
13) Which of the following algorithm does not alter the container objects?
- Mutating algorithm
- Non-Mutating algorithm
- Both
- None
Correct Answer - 2
Non-Mutating algorithm
Explanation:
The non-mutating algorithm does not alter the container objects.
14) Which of the following statements are correct about function objects in C++?
- A function object is a function that wrapped in class then it looks like objects.
- Function objects are faster than normal functions.
- Function objects contain attributes and member functions.
- Function objects are slower than normal functions.
Options:
- A and B
- A and C
- A, B, and C
- A, C, and D
Correct Answer - 3
A, B, and C
Explanation:
Statements A, B, and C are correct about function objects in C++.
15) A function object is also known as functor?
- Yes
- No
Correct Answer - 1
Yes
Explanation:
Yes, a function object is also known as functor.