MCQ Bank
If a class is inherited using private inheritance, what happens to public members of the base class?
- A) Become protected
- B) Become private
- C) Become inaccessible
- D) Remain public
Which of the following access specifier ensures that base class member is accessible in derived class of this base class and NOT outside of this class?
- A) protected
- B) Static
- C) public
- D) private
Which class has at least one pure virtual function?
- A) Abstract class
- B) Child class
- C) Template class
- D) Concrete class
In case of protected inheritance, public members of base class will be _____________ in derived class.
- A) protected
- B) hidden
- C) private
- D) public
In C++, a function is made pure virtual by adding ____________ at the end of its declaration.
- A) = -1
- B) = 0
- C) = 2
- D) = 1
___________ binding means that target function for a call is selected at run time.
- A) Static
- B) Constant
- C) Automatic
- D) Dynamic
What is function overriding in C++?
- A) Calling a function multiple times
- B) Redefining a base class function in a derived class
- C) Using global functions inside a class
- D) Defining multiple functions with the same name in one class
In which of the following way(s), we can inherit a class from another class in C++?
- A) Protected
- B) Private
- C) Public
- D) All of the given options
Which casting in C++ involves a runtime check and returns a null pointer if the conversion is not possible?
- A) Static cast
- B) Const cast
- C) Reinterpret cast
- D) Dynamic cast
Which of the following is not type of inheritance in C++?
- A) private
- B) public
- C) restricted
- D) protected
In C++, which of the following operator can only be overloaded as a member function of the class?
- A) Stream Extraction Operator: >>
- B) Inequality Operator: !=
- C) Equality Operator: ==
- D) Function Operator: ()
In C++, the subscript operator [] must be overloaded as a _______ of the class, with one parameter of _______ type.
- A) Member function, char
- B) Member function, int
- C) Non-member function, char
- D) Non-member function, int
Which of the following is NOT a form of polymorphism?
- A) Function overloading
- B) Encapsulation
- C) Operator overloading
- D) Function overriding
Which of the following function can convert a class into an abstract class?
- A) Pure virtual function
- B) Concrete function
- C) Abstract function
- D) Virtual function
Which condition is necessary for function overriding?
- A) Static keyword
- B) Different function names
- C) Same function name + same parameters + inheritance
- D) Same function name only
<p>__________ binding means that target function for a call is selected at compile time.</p>
- A) <p>Dynamic</p>
- B) <p>Default</p>
- C) <p>Static</p>
- D) <p>Automatic</p>
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 run time
- B) An error at compile-time.
- C) A warning at compile-time.
- D) An error at runtime.
What is the general syntax of overloading Unary Operator as member function of the class?
- A) TYPE & operator OP (int);
- B) TYPE & operator OP (TYPE &, TYPE &);
- C) TYPE & operator OP ();
- D) TYPE & operator OP (TYPE &);
If a class does not define any constructor, which constructor will be automatically created by the compiler?
- A) Explicit Default Constructor
- B) Implicit Parameterized Constructor
- C) Explicit Parameterized Constructor
- D) Implicit Default Constructor
Which of the following operators operate on one operand?
- A) Binary Operators
- B) Assignment Operator
- C) Ternary Operator
- D) Unary Operators