Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

Q391: What does the following code snippet demonstrate? Person::GetName() within Student::Print()
  • A: Implicit call to base class method
  • B: Explicit call to base class method
  • C: Overriding base class method
  • D: Hiding base class method
View Answer
B

Q392: When is a copy constructor called?
  • A: When an object is assigned to another existing object
  • B: When an object goes out of scope
  • C: When a new object is created from an existing object
  • D: When an object is deleted
View Answer
C

Q393: What is the correct order of constructor calls when creating an object of a derived class?
  • A: Derived class constructor first, then base class constructor
  • B: Base class constructor first, then derived class constructor
  • C: Random order
  • D: Only derived class constructor is called
View Answer
B

Q394: In the context of inheritance, which member function is responsible for cleaning up dynamic memory?
  • A: Constructor
  • B: Destructor
  • C: Copy constructor
  • D: Assignment operator
View Answer
B

Q395: What does 'deep copy' mean in the context of object copying?
  • A: Copying only primitive data members
  • B: Copying all data members including dynamically allocated memory
  • C: Copying object address
  • D: Copying object methods only
View Answer
B

Q396: Which C++ feature allows derived class objects to be treated as base class objects?
  • A: Polymorphism
  • B: Encapsulation
  • C: Abstraction
  • D: Inheritance
View Answer
D

Q397: In the example provided, what is the result of assigning sobj1 to sobj2 without a user-defined assignment operator?
  • A: Shallow copy occurs
  • B: Deep copy occurs
  • C: Compile-time error
  • D: Runtime error
View Answer
A

Q398: What is the purpose of the const keyword at the end of member function declarations?
  • A: To prevent the function from modifying class members
  • B: To make the function public
  • C: To allow function overloading
  • D: To make the function static
View Answer
A

Q399: In C++, what does the following statement do? Derived* derived = dynamic_cast<Derived*>(base);
  • A: Converts base class pointer to derived class pointer safely
  • B: Converts derived class pointer to base class pointer
  • C: Performs a compile-time check
  • D: Causes a compile-time error
View Answer
A

Q400: What will happen if you attempt to downcast using static_cast and the types are not compatible?
  • A: Safe conversion occurs
  • B: Compile-time error
  • C: Undefined behavior
  • D: The program crashes
View Answer
C

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now