Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q581: In the resolution order of template specializations, which specialization is checked first?
- A: Partial specialization
- B: General template
- C: Complete specialization
- D: None of the above
View Answer
C
Q582: When the compiler searches for template specializations, it starts from more ______ to more ______.
- A: specific, general
- B: specific, specialized
- C: general, specific
- D: specialized, specific
View Answer
A
Q583: Rule 1 states that when an ordinary function or class is declared as a friend of a class template, it becomes a friend of ______.
- A: only the class template instantiated for the same type
- B: all instantiations of that template class
- C: none of the instantiations of that template class
- D: some instantiations of that template class
View Answer
B
Q584: Which of the following is true about Rule 2 in template and friend functions/classes?
- A: A template friend function or class template is instantiated with the same type parameters of the class template granting friendship.
- B: All instantiations of the friend function or class are friends of the class template.
- C: Only one specific instantiation of the friend function or class is considered a friend.
- D: None of the above
View Answer
A
Q585: In the context of template and friend functions, what happens if you instantiate a friend template function with a different type than the class template?
- A: The instantiation of the friend function will be a friend of the class template.
- B: The instantiation of the friend function will not be a friend of the class template.
- C: The friend function will be instantiated with the same type parameters as the class template.
- D: None of the above
View Answer
B
Q586: Rule 3 of templates and friends says that if a friend function or class template takes different type parameters from the class template granting friendship, then ______.
- A: its each instantiation is a friend of each instantiation of the class template
- B: its each instantiation is not a friend of the class template
- C: its instantiation must match the type parameters of the class template
- D: none of the above
View Answer
A
Q587: When a template class is declared as a friend of another class template, which types of specializations become friends?
- A: Only explicit specializations
- B: Only implicit specializations
- C: All kinds of specializations including explicit, implicit, and partial
- D: None of the above
View Answer
C
Q588: If a template function is declared as a friend of a class template, which of the following is true?
- A: All instantiations of that function become friends of the class template only for specific types
- B: All instantiations of the function become friends of the class template for all types
- C: Only the specific instantiation of the function that is used is a friend
- D: None of the above
View Answer
B
Q589: In a template class, when you declare a template function as a friend, what type of template function becomes a friend of the class?
- A: Only the exact template function instantiated with the same type parameters
- B: Only general template functions
- C: Only partial template functions
- D: All template functions including explicit, implicit, and partial
View Answer
D
Q590: In Rule 4, when a template is declared as a friend of any class, which of the following also becomes friends of the class?
- A: Only the explicit specializations of that function or class
- B: Only the implicit specializations of that function or class
- C: All specializations including explicit, implicit, and partial
- D: None of the above
View Answer
C