Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q601: How many separate copies of static data members are created for different data types in a template class?
- A: One
- B: Two
- C: Three
- D: Four
View Answer
B
Q602: Which rule states that when a function template or class template is a friend of a template class, it becomes a friend for each instantiation of that template class for a specific type?
- A: Rule 1
- B: Rule 2
- C: Rule 3
- D: Rule 4
View Answer
B
Q603: Fill in the blank: When an ordinary function or class is declared as a friend of a template class, it becomes a friend of each _______ of that template class.
- A: instantiation
- B: method
- C: static member
- D: object
View Answer
A
Q604: In the provided find function template, what operations are necessary for a container to be compatible with this algorithm?
- A: Increment operator and dereferencing operator only
- B: Increment operator, dereferencing operator, and inequality operator
- C: Only dereferencing operator
- D: Only inequality operator
View Answer
B
Q605: Fill in the blank: In the find function template, the P parameter represents the type of _______ used for traversal in the algorithm.
- A: iterator
- B: container
- C: function
- D: class
View Answer
A
Q606: What will happen if you try to use the find function with a container that does not support the increment operator?
- A: Compilation will fail
- B: The function will return incorrect results
- C: The function will still work as expected
- D: The container will be ignored
View Answer
A
Q607: In the Vector class example, what data type is the index data member used to track?
- A: Size
- B: Traversal position
- C: Value
- D: Capacity
View Answer
B
Q608: What does Rule 4 state about friend templates in relation to specializations?
- A: All specializations of the friend template become friends
- B: Only explicit specializations become friends
- C: Only partial specializations become friends
- D: Specializations are not considered friends
View Answer
A
Q609: Fill in the blank: If a template class A is declared as a friend of a template class B, then the friend declaration applies to _______ specializations of A.
- A: explicit, implicit, and partial
- B: only explicit
- C: only partial
- D: only implicit
View Answer
A
Q610: In the context of cursors, what does the `beyond()` method return?
- A: The first element of the container
- B: The last element of the container
- C: The pointer just past the last element
- D: The pointer to the middle element
View Answer
C