Explore topic-wise MCQs in Object Oriented Programming.

This section includes 14 Mcqs, each offering curated multiple-choice questions to sharpen your Object Oriented Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

Template classes must have at least one static member.

A. True
B. False
Answer» C.
2.

How many generic types can be given inside a single template class?

A. Only 1
B. Only 3
C. Only 7
D. As many as required
Answer» E.
3.

If template class is defined, is it necessary to use different types of data for each call?

A. No, not necessary
B. No, but at least two types must be there
C. Yes, to make proper use of template
D. Yes, for code efficiency
Answer» B. No, but at least two types must be there
4.

What if static members are declared inside template classes?

A. All instances will share the static variable
B. All instances will have their own static variable
C. All the instances will ignore the static variable
D. Program gives compile time error
Answer» C. All the instances will ignore the static variable
5.

How is function overloading different from template class?

A. Overloading is multiple function doing same operation, Template is multiple function doing different operations
B. Overloading is single function doing different operations, Template is multiple function doing different operations
C. Overloading is multiple function doing similar operation, Template is multiple function doing identical operations
D. Overloading is multiple function doing same operation, Template is same function doing different operations
Answer» D. Overloading is multiple function doing same operation, Template is same function doing different operations
6.

The _____________ class is a specialization of a more general template class.

A. String
B. Integer
C. Digit
D. Math
Answer» B. Integer
7.

Can typeid() function be used with the object of generic classes?

A. Yes, only if default type is given
B. Yes, always
C. No, generic data can’t be determined
D. No, never possible
Answer» C. No, generic data can’t be determined
8.

What are the two specializations of I/O template classes in C++?

A. 16-bit character and wide characters
B. 8-bit character and wide characters
C. 32-bit character and locale characters
D. 64-bit characters and locale characters
Answer» C. 32-bit character and locale characters
9.

A template class defines the form of a class _____________________ it will operate.

A. With full specification of the data on which
B. With full specification of the functions on which
C. Without full specification of the data on which
D. Without full specification of the functions on which
Answer» D. Without full specification of the functions on which
10.

Which is the most significant feature that arises by using template classes?

A. Code readability
B. Ease in coding
C. Code reusability
D. Modularity in code
Answer» D. Modularity in code
11.

What is the syntax to use explicit class specialization?

A. template <int> class myClass<>{ }
B. template <int> class myClass<int>{ }
C. template <> class myClass<>{ }
D. template <> class myClass<int>{ }
Answer» E.
12.

Can default arguments be used with the template class?

A. Yes, in some special cases
B. Yes, always
C. No, it must satisfy some specific conditions first
D. No, it can’t be done
Answer» C. No, it must satisfy some specific conditions first
13.

Which among the following is the proper syntax for the template class?

A. template <typename T1, typename T2>;
B. Template <typename T1, typename T2>;
C. template <typename T> T named(T x, T y){ }
D. Template <typename T1, typename T2> T1 named(T1 x, T2 y){ }
Answer» D. Template <typename T1, typename T2> T1 named(T1 x, T2 y){ }
14.

A template class can have _____________

A. More than one generic data type
B. Only one generic data type
C. At most two data types
D. Only generic type of integers and not characters
Answer» B. Only one generic data type