ProgrammingHardGATE CS · TCS NQT Prime · Product Company SDE

Which statement about C++ vtables is correct for a class with multiple virtual functions?

  1. A. Vtables only exist for classes with no data members
  2. B. All of a class's virtual functions share one single vtable for that class, indexed by function slot
  3. C. The vtable is recreated for every object individually
  4. D. Each virtual function gets its own separate vtable

Correct answer: B. All of a class's virtual functions share one single vtable for that class, indexed by function slot

A class gets exactly one vtable listing all of its virtual functions; every instance's vptr points to that same shared table.

More OOP with C++ and Java questions

Exams that ask this topic