Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q571: In the given code snippet, which template specialization is used for `Vector<char*>`?
- A: Partial specialization
- B: General template
- C: Complete specialization
- D: None of the above
View Answer
C
Q572: Which function template specialization is used for `sort(str)` in the example?
- A: Complete specialization for `char*`
- B: Partial specialization for `Vector
` - C: General template for `T`
- D: Ordinary function sort(char*)
View Answer
A
Q573: Which resolution order does the compiler follow for function templates?
- A: Complete specialization, Partial specialization, General template, Ordinary function
- B: Ordinary function, Complete specialization, Partial specialization, General template
- C: General template, Partial specialization, Complete specialization, Ordinary function
- D: Partial specialization, Ordinary function, Complete specialization, General template
View Answer
B
Q574: In the example provided, which class can inherit from a partial specialization?
- A: A class template
- B: Complete specialization
- C: Ordinary class
- D: None of the above
View Answer
A
Q575: In the code `template<class T> class A {}; template<class T> class B : public A<T> { ... };`, which class is derived from the class template `A`?
- A: A
- B: B
- C: A class template that is not specified
- D: A derived class with less parameters
View Answer
B
Q576: The resolution order for function templates includes which of the following?
- A: Partial specialization, General template, Complete specialization, Ordinary function
- B: Ordinary function, Complete specialization, General template, Partial specialization
- C: General template, Partial specialization, Complete specialization, Ordinary function
- D: Complete specialization, Ordinary function, Partial specialization, General template
View Answer
B
Q577: In the example where `B< T* > : public A< T* >`, which class is used for inheritance?
- A: A< T* >
- B: B< T* >
- C: A< int* >
- D: B< int* >
View Answer
A
Q578: A function template can be overloaded with which of the following?
- A: Partial specialization
- B: Complete specialization
- C: Ordinary function
- D: All of the above
View Answer
D
Q579: When using a template class, the derived class must match the base class in what aspect?
- A: Number of template parameters
- B: Function signatures
- C: Class names
- D: Template arguments
View Answer
A
Q580: In C++, when a function or class is declared as a friend of a class template, it becomes a friend of ______.
- A: all instantiations of that template class
- B: some instantiations of that template class
- C: only the specific instantiation that is used
- D: none of the instantiations of that template class
View Answer
A