C++ Programming Multiple Choice Questions - Templates
This section focuses on the "Templates" in C++ programming langauge. These Multiple Choice Questions (MCQ) should be practiced to improve the C++ programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which value is placed in the base class?
A. Derived values
B. Default type values
C. Both default type & derived values
D. None of the above
View Answer
Ans : B
Explanation: We can place the default type values in a base class and overriding some of them through derivation.
2. What is a template?
A. A template is a formula for creating a generic class
B. A template is used to manipulate the class
C. A template is used for creating the attributes
D. None of the above
View Answer
Ans : A
Explanation: A template is a formula for creating a generic class
3. Which of the following best defines the syntax for template function ?
A. template return_type Function_Name(Parameters)
B. template return_type Function_Name(Parameters)
C. Both A and B
D. None of the above
View Answer
Ans : C
Explanation: Both A or B is the syntax for template function.
4. Templates are abstract recipe for producing a concrete code, and it is used for
A. Producing functions
B. Producing classes
C. Nothing
D. Both A and B
View Answer
Ans : D
Explanation: Templates are abstract recipe for producing a concrete code, and it is used for Both A and B options.
5. How many parameters are legal for non-type template?
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : D
Explanation: The following are legal for non-type template parameters: integral or enumeration type, Pointer to object or pointer to function, Reference to object or reference to function, Pointer to member.
6. How many kinds of entities are directly parameterized in c++?
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : C
Explanation: C++ allows us to parameterize directly three kinds of entities through templates: types, constants, and templates
7. From where does the template class derived?
A. Regular non-templated C++ class
B. Templated class
C. Both A or B
D. None of the above
View Answer
Ans : C
Explanation: The template class derived Both A or B
8. Can we have overloading of the function templates?
A. Yes
B. No
C. May Be
D. Can't Say
View Answer
Ans : A
Explanation: Yes, we have overloading of the function templates.
9. A container class is a class whose instances are
A. Containers
B. Functions
C. Strings
D. None of the above
View Answer
Ans : A
Explanation: A container class is a class whose instances are Containers.
10. Which of the things does not require instantiation?
A. Functions
B. Non virtual member function
C. Member class
D. All of the above
View Answer
Ans : D
Explanation: All of the above things does not require instantiation.
Also check :
Discussion