MCQ Bank
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
___________ may inherit from a complete specialization.
- A) Complete specialization
- B) Ordinary class
- C) All of the given options
- D) Partial specialization
In C++, which of the following operator can only be overloaded as a member function of the class?
- A) Equality Operator: ==
- B) Function Operator: ()
- C) Inequality Operator: !=
- D) Stream Extraction Operator: >>
___________ binding means that target function for a call is selected at run time.
- A) Automatic
- B) Constant
- C) Static
- D) Dynamic
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>protected: void func1();</p> <p>};</p> <p>class class2 : private class1</p> <p>{ };</p> <p>Function func1 of class1 is ______ in class2.</p>
- A) <p>static</p>
- B) <p>public</p>
- C) <p>private/hidden</p>
- D) <p>protected</p>
Which of the following is NOT casting operator in C++ standard?
- A) reinterpret_cast
- B) dynamic_cast
- C) static_cast
- D) var_cast
Which condition is necessary for function overriding?
- A) Same function name + same parameters + inheritance
- B) Different function names
- C) Static keyword
- D) Same function name only
What is the general syntax of overloading Unary Operator as member function of the class?
- A) TYPE & operator OP (TYPE &, TYPE &);
- B) TYPE & operator OP (int);
- C) TYPE & operator OP (TYPE &);
- D) TYPE & operator OP ();
Compiler generated copy constructor performs __________.
- A) Shallow copy
- B) Deep copy
- C) Both Shallow and Deep copy
- D) Bitwise copy
Suppose you have following C++ statements: int oldValue=10; int newValue = oldValue ++; What will be the value of oldValue and newValue after executing above statements?
- A) oldValue= 10 , newValue=10
- B) oldValue= 10 , newValue=11
- C) oldValue= 11 , newValue=11
- D) oldValue= 11 , newValue=10
In function overriding, if the return types of the base class function and the derived class function are different, it leads to:
- A) A warning at compile-time.
- B) An error at compile-time.
- C) A warning at run time
- D) An error at runtime.