Practice 20 Inheritance multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.
Show Answer & Explanation
Correct Answer: B — Multiple
Multiple inheritance causes diamond problem when two parent classes inherit from same grandparent.
Show Answer & Explanation
Correct Answer: B — Virtual inheritance
Virtual inheritance ensures only one copy of base class members.
Show Answer & Explanation
Correct Answer: C — Public in derived
In public inheritance, public members remain public in derived class.
Show Answer & Explanation
Correct Answer: A — Private in derived
In private inheritance, public members become private in derived class.
Show Answer & Explanation
Correct Answer: B — Before derived constructor
Base class constructor is called first, then derived class constructor.
Show Answer & Explanation
Correct Answer: B — Derived first
Destructors are called in reverse order: derived first, then base.
Show Answer & Explanation
Correct Answer: B — Chain of inheritance (A→B→C)
Multilevel: A derives B, B derives C (chain).
Show Answer & Explanation
Correct Answer: A — One base, multiple derived
Hierarchical: multiple classes derive from one base class.
Show Answer & Explanation
Correct Answer: B — Inherited but not accessible
Private members are inherited but not directly accessible in derived class.
Show Answer & Explanation
Correct Answer: B — Protected
Protected members remain protected in public inheritance.
Show Answer & Explanation
Correct Answer: B — Before derived constructor
Base class constructor is always called first before the derived class constructor.
Show Answer & Explanation
Correct Answer: B — Derived first, then base
Destructors are called in reverse order: derived class destructor first, then base class.
Show Answer & Explanation
Correct Answer: C — Using member initializer list
In C++, base class constructor is called using member initializer list: Derived() : Base() {}.
Show Answer & Explanation
Correct Answer: B — Combination of two or more types
Hybrid inheritance combines multiple types of inheritance like hierarchical and multiple.
Show Answer & Explanation
Correct Answer: B — Protected
In protected inheritance, public members of base class become protected in derived class.
Show Answer & Explanation
Correct Answer: B — Prevents inheritance
A class declared as final cannot be inherited by any other class.
Show Answer & Explanation
Correct Answer: C — Both base and derived objects
Base class pointer can point to both base and derived class objects (upcasting).
Show Answer & Explanation
Correct Answer: C — Constructors
Constructors and destructors are not inherited; derived class must define its own.
Show Answer & Explanation
Correct Answer: B — Changes access of inherited member
using Base::member can change the access level of inherited members in derived class.
Show Answer & Explanation
Correct Answer: B — Base members + derived members
Size of derived class includes size of base class members plus derived class members.