MCQ Bank
___________ 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.
Which class has at least one pure virtual function?
- A) Concrete class
- B) Template class
- C) Child class
- D) Abstract class
In case of public inheritance, protected members of base class will be _____________ in derived class.
- A) protected
- B) public
- C) hidden
- D) private
Which statement will be true for concrete class?
- A) None of given options.
- B) It can be instantiated.
- C) It cannot be inherited from an abstract class.
- D) It cannot be instantiated.
If a class is inherited using private inheritance, what happens to public members of the base class?
- A) Become inaccessible
- B) Become protected
- C) Remain public
- D) Become private
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p> private: int i;</p> <p>};</p> <p>class class2 : protected class1</p> <p>{ };</p> <p>Then int member i of class1 is ______ in class2.</p>
- A) <p>static</p>
- B) <p>protected</p>
- C) <p>public</p>
- D) <p>private</p>
Which of the following operators operate on one operand?
- A) Unary Operators
- B) Binary Operators
- C) Ternary Operator
- D) Assignment Operator
Target class of a _______ function call is determined at run time.
- A) Virtual
- B) Non- Virtual
- C) Operator
- D) Instance
If we have not given any constructor for the class, compiler generates which of the following constructors?
- A) Implicit Default Constructor
- B) Implicit Parameterized Constructor
- C) Explicit Default Constructor
- D) Explicit Parameterized Constructor
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 obj<>int;
- B) Vector <int> obj;
- C) Vector obj <int>;
- D) Vector int obj;
To remove leading '#' characters, which should you use?
- A) s.lstrip('#')
- B) s.strip('#')
- C) s.rstrip('#')
- D) s.strip()