MCQ Bank
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
<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>protected</p>
- B) <p>static</p>
- C) <p>private/hidden</p>
- D) <p>public</p>
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>private: void func1();</p> <p>};</p> <p>class class2 : protected class1</p> <p>{ };</p> <p>Function func1 of class1 is ______ in class2.</p>
- A) <p>private/hidden</p>
- B) <p>public</p>
- C) <p>static</p>
- D) <p>protected</p>
Which of the following is an example of unary operator?
- A) Equality Operator ( = =)
- B) Increment Operator ( ++ )
- C) Division Operator ( / )
- D) Inequality Operator ( != )
Consider the following C++ code fragment written for a class Student: Student sobj1; Student sobj2(sobj1); Upon execution of second statement, which constructor of Student class will be called?
- A) Copy constructor of Student class
- B) Both Default and Copy constructor of Student class
- C) Default constructor of Student class
- D) Parameterized constructor of Student class
Compiler generated copy constructor performs __________.
- A) Shallow copy
- B) Both Shallow and Deep copy
- C) Deep copy
- D) Bitwise copy
Which of the following is pure virtual function?
- A) virtual void print() = 0;
- B) void print();
- C) virtual void print();
- D) void print() = 0;
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= 11 , newValue=10
- C) oldValue= 10 , newValue=11
- D) oldValue= 11 , newValue=11
A post-fix unary operator is implemented in C++ using non-member function with __________ argument(s).
- A) Three
- B) One
- C) Two
- D) Zero
<p>Consider the code below:</p> <p>class class1</p> <p>{</p> <p>protected: int i;</p> <p>};</p> <p>class class2 : private class1</p> <p>{ };</p> <p>Then int member i 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 known as Dereference operator in C++?
- A) ::
- B) *
- C) +
- D) &