Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q361: In C++, what will happen if a derived class does not define a destructor?
- A: Base class destructor will be called first
- B: No destructor will be called
- C: Derived class destructor will be called
- D: Only base class destructor will be called
View Answer
A
Q362: What does a default constructor allow?
- A: Create class object with no arguments
- B: Create class object with arguments
- C: Prevent class instantiation
- D: Access private members of the class
View Answer
A
Q363: What happens if a base class has only a non-default constructor?
- A: Derived class inherits it
- B: Compiler generates a default constructor
- C: Compiler generates an error
- D: Constructor is ignored
View Answer
C
Q364: How can a base class's non-default constructor be called in a derived class?
- A: Through base class object
- B: In derived class constructor
- C: Through a public method
- D: By using friend function
View Answer
B
Q365: What is the purpose of the IsLeapYear function in the Date class?
- A: To set the day
- B: To check if a year is a leap year
- C: To add a day
- D: To reset the date
View Answer
B
Q366: Why are helper functions often made private?
- A: To prevent external access
- B: To ensure faster execution
- C: To allow inheritance
- D: To improve readability
View Answer
A
Q367: Which access specifier should be used to allow derived classes to access a function but not external classes?
- A: Public
- B: Private
- C: Protected
- D: Friend
View Answer
C
Q368: What is the primary disadvantage of using protected members?
- A: Increases accessibility
- B: Breaks encapsulation
- C: Enhances performance
- D: Reduces code readability
View Answer
B
Q369: What does public inheritance model?
- A: "HAS A" relationship
- B: "DOES A" relationship
- C: "IS A" relationship
- D: "WILL BE A" relationship
View Answer
C
Q370: When can a derived class object be used?
- A: When base class object is required
- B: When base class object is not required
- C: Only in special cases
- D: Never
View Answer
A