MCQ Bank
In case of template specialization, if compiler cannot find required complete specialization then it searches for some _____________________.
- A) General Template
- B) Complete Specialization
- C) None of the given options
- D) Partial Specialization
In resolution order of function templates, compiler searches for _____________ in the end.
- A) generic template
- B) complete specialization
- C) partial specialization
- D) ordinary function
Which of the following is correct code to instantiate the object of given template Vector class for int type?
template <class T>
class Vector
{
};
- A) Vector <int> obj;
- B) Vector int obj;
- C) Vector obj<>int;
- D) Vector obj <int>;
Which of the following represents partial specialization?
- A) template< int , char >
- B) template< class T, class U, int >
- C) template< typename T, class W >
- D) template< class T, type T>
Polymorphism always works with ___________.
- A) pointer to class objects
- B) constant objects
- C) static objects
- D) actual objects
When we specialize a function template, it is called _____________________.
- A) function overloading
- B) function overriding
- C) function template overloading
- D) function template overriding
When we want to have exactly identical operations on different data types, ______________ are used.
- A) Function Overloading
- B) None of the given options
- C) Function Overriding
- D) Function Templates
Which of the following is correct way to define a template class X?
- A) typename <class T > class X { };
- B) template< typename T > class X { };
- C) template class X { };
- D) class< typename T > class X { };
Which of the following may inherit from an ordinary class?
- A) All of the given options
- B) Complete specialization
- C) Partial specialization
- D) Class template
Which of the following can be passed as type arguments to templates?
- A) None of the given options
- B) Both Primitive types and User-defined types
- C) User-defined types
- D) Primitive types
We can change behavior of a template using __________.
- A) Class Templates
- B) Template Parameters
- C) Function Templates
- D) None of the given options
Each ___________ of a template class by default becomes function template.
- A) Type parameter
- B) Data member
- C) Object
- D) Member function
The parameters given in template definition other than those used for mentioning templates types are called ____________.
- A) Type Parameters
- B) None of the given options
- C) Non-Type Parameters
- D) Default Type Parameters
In resolution order, compiler searches for _________ firstly.
- A) Generic Template
- B) Ordinary function
- C) Complete Specialization
- D) Partial Specialization
Consider the following class "phone" which is inheriting from "Transmit" and "Receiver". Which of the following line of code will produce error. Class phone: public Transmit, public Receiver { }; 1. int main() 2. { 3. phone obj; 4. Tranmit* obj1 = &obj; 5. Received obj2 = &obj; 6. }
- A) 3rd and 4th line will produce error.
- B) 5th line will produce error
- C) 4th line will produce error
- D) 3rd line will produce error
In statement "template <class T, class U, int I = 5>" ,the non-type parameter is _____________.
- A) class U
- B) class T
- C) int I
- D) All of the given options
In resolution order, highest priority is given to __________________ in template specialization.
- A) partial specialization
- B) general template
- C) none of the given options
- D) complete specialization
Which of the following is the correct syntax for passing two type arguments to a template?
- A) template< type T, type U >
- B) template< type T, U >
- C) template Typename< T, U >
- D) template< typename T, typename U >
Which of the following represents complete specialization?
- A) template< class class W >
- B) template< class T, float >
- C) template< class T, class U, int >
- D) template< int , char >
_________________ class is a single class that provides functionality to operate on different types of data.
- A) None of the given options
- B) Template
- C) Friend
- D) Ordinary