MCQs – C++ Polymorphism


Q) Which is the correct declaration of pure virtual function in C++
  1. virtual void func = 0;
  2. virtual void func() = 0;
  3. virtual void func(){0};
  4. void func() = 0;

Answer: 2

virtual void func() = 0; is the correct declaration.


Q) In a class, pure virtual functions in C++ is used
  1. To create an interface
  2. To make a class abstract
  3. To force derived class to implement the pure virtual function
  4. All the above

Answer: 4

All are correct. Recommended to read abstract class in c++ with example that uses pure virtual function.


Q) Which public member of a base class cannot be inherited?
  1. Constructor
  2. Destructor
  3. Both A & B
  4. Only B

Answer: 3

In C++ constructor and destructor both cannot be inherited to child class.


Q) How many VPTR is created internally for a base class and a derived class
  1. 0
  2. 1
  3. 2
  4. 3

Answer: 2


Q) Number of virtual table created for a base and a derived class is
  1. 0
  2. 1
  3. 2
  4. 3

Answer: 3


MCQs – C++ Polymorphism
Scroll to top