Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Chapter: 25
Q421:
How can recursive calls be avoided when overriding methods in C++?
A. By using this->methodName()
B. By calling baseClass::methodName()
C. By avoiding method overloading
D. By using different method names
Correct Answer:
B
Chapter: 25
Q422:
Function overriding can be avoided by using:
A. Different method names
B. Pointers
C. Virtual functions
D. Static methods
Correct Answer:
C
Chapter: 25
Q423:
Function overloading is done within the scope of:
A. Two different classes
B. A single class
C. Multiple inheritance
D. Multiple classes
Correct Answer:
B
Chapter: 25
Q424:
Inheritance hierarchy in OOP is represented in which form?
A. Tree-like structure
B. Circular structure
C. Linked list
D. Graph
Correct Answer:
A
Chapter: 26
Q425:
What does the child class call during initialization in the constructor initialization list?
A. Direct base class constructor
B. Indirect base class constructor
C. Any constructor available
D. None of the above
Correct Answer:
A
Chapter: 26
Q426:
Which class's constructor cannot be called by the child class during its initialization?
A. Direct base class constructor
B. Indirect base class constructor
C. Both direct and indirect base class constructors
D. Only the grandparent class constructor
Correct Answer:
B
Chapter: 26
Q427:
What error occurs if the child class tries to call an indirect base class constructor in its initialization list?
A. Syntax error
B. Logic error
C. Compilation error
D. None of the above
Correct Answer:
C
Chapter: 26
Q428:
In the given code, what will be the output when Child1 obj; obj.Print(); is called?
A. GrandParent::Print
B. Parent1::Print
C. Child1::Print
D. Compilation error
Correct Answer:
C
Chapter: 26
Q429:
Which types of inheritance allow public members of the base class to remain public in the derived class?
A. Private inheritance
B. Protected inheritance
C. Public inheritance
D. All of the above
Correct Answer:
C
Chapter: 26
Q430:
Which type of inheritance hides the private members of the base class in the derived class?
A. Public inheritance
B. Protected inheritance
C. Private inheritance
D. None of the above
Correct Answer:
D
Chapter: 26
Q431:
Which keyword specifies that members of a base class should be inherited as private in the derived class?
A. Private
B. Public
C. Protected
D. None of the above
Correct Answer:
A
Chapter: 26
Q432:
What is the relationship modeled by private inheritance in C++?
A. "Is-a" relationship
B. "Has-a" relationship
C. "Implemented in terms of" relationship
D. "Uses-a" relationship
Correct Answer:
C
Chapter: 26
Q433:
In private inheritance, which methods of the base class can be accessed from outside the derived class?
A. All methods
B. Only public methods
C. No methods
D. Only protected methods
Correct Answer:
C
Chapter: 26
Q434:
Why is private inheritance used in the given example of class Set and Collection?
A. To allow all base class functions to be accessed
B. To remove extra features and protect the interface
C. To make the base class accessible from outside
D. To allow duplicate elements
Correct Answer:
B
Chapter: 26
Q435:
What functionality does the AddElement method provide in the Collection class?
A. Adds elements without checking for duplicates
B. Adds only unique elements
C. Searches for an element
D. Deletes elements
Correct Answer:
A
Chapter: 26
Q436:
What will happen if the SearchElement method finds an element in the Collection?
A. It returns true immediately
B. It continues to search
C. It returns false
D. It deletes the element
Correct Answer:
A
Chapter: 26
Q437:
What is the primary difference between the Set class and the Collection class?
A. Set allows duplicate elements
B. Collection does not allow duplicates
C. Set does not allow duplicate elements
D. Collection does not perform search operations
Correct Answer:
C
Chapter: 26
Q438:
When should private inheritance be used instead of public inheritance?
A. When all base class functions are needed
B. When only some base class functions are needed
C. When no base class functions are needed
D. When all base class functions should be hidden
Correct Answer:
B
Chapter: 27
Q439:
In private inheritance, who can access the base class's member functions?
A. Any class
B. Derived class and its friends
C. Only derived class
D. Public functions only
Correct Answer:
B
Chapter: 27
Q440:
What relationship is modeled by private inheritance?
A. "Is a type of"
B. "Has a"
C. "Implemented in terms of"
D. "Uses a"
Correct Answer:
C