Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

Q471: If a class has at least one pure virtual function, it is known as:
  • A: A Concrete Class
  • B: A Virtual Class
  • C: A Derived Class
  • D: An Abstract Class
View Answer
D

Q472: Fill in the blank: A class with no implementation for some methods is referred to as a(n) ______ class.
  • A: Concrete
  • B: Abstract
  • C: Derived
  • D: Static
View Answer
B

Q473: Which of the following classes is abstract?
  • A: class Shape { public: virtual void draw() = 0; };
  • B: class Rectangle { public: void draw() { } };
  • C: class Quadrilateral { public: void draw() { } };
  • D: class Circle { public: void draw() { } };
View Answer
A

Q474: When using virtual functions, which of the following is true?
  • A: The compiler generates code to access the vTable.
  • B: The vTable contains pointers to all functions in a class.
  • C: The base class pointer can only point to base class objects.
  • D: The derived class must have a non-virtual destructor.
View Answer
A

Q475: In the context of virtual functions, what is Dynamic Dispatch?
  • A: Accessing the appropriate function at runtime using the vTable
  • B: Calling the function directly based on the class type
  • C: Accessing the function's implementation at compile time
  • D: Binding functions to their addresses at compile time
View Answer
A

Q476: Which of the following scenarios will lead to a compiler error?
  • A: Creating an instance of a class with pure virtual functions.
  • B: Calling a virtual function from a base class pointer.
  • C: Overriding a pure virtual function in a derived class.
  • D: Using a derived class object to call a base class method.
View Answer
A

Q477: What will happen if you delete a base class pointer that points to a derived class object without making the base class destructor virtual?
  • A: The derived class destructor will be called.
  • B: Only the base class part of the object will be deleted.
  • C: Memory leaks will be avoided.
  • D: The derived class object will be deleted correctly.
View Answer
B

Q478: Fill in the blank: When a class's virtual function is overridden, the derived class will use its own version of the function, while the base class's version is ______.
  • A: Overridden
  • B: Shadowed
  • C: Called
  • D: Unchanged
View Answer
B

Q479: What is the purpose of making a destructor virtual in a base class?
  • A: To ensure that derived class destructors are called when deleting a base class pointer.
  • B: To prevent base class destructors from being called.
  • C: To allow the base class destructor to access derived class methods.
  • D: To avoid having a destructor in the derived classes.
View Answer
A

Q480: Which of the following best describes the use of pure virtual functions in C++?
  • A: They allow a class to provide a default implementation for derived classes.
  • B: They force derived classes to provide their own implementation of the function.
  • C: They are used to define static functions that cannot be overridden.
  • D: They enable classes to be instantiated directly.
View Answer
B

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now