Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

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
View Answer
A

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
View Answer
C

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
View Answer
C

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
View Answer
B

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
View Answer
A

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
View Answer
A

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
View Answer
C

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
View Answer
B

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
View Answer
B

Q440: What relationship is modeled by private inheritance?
  • A: "Is a type of"
  • B: "Has a"
  • C: "Implemented in terms of"
  • D: "Uses a"
View Answer
C

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now