OOP with C++

Inheritance — Practice MCQs for CCAT

20 Questions Section B: Programming OOP with C++

Practice 20 Inheritance multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.

Q1.
Which inheritance leads to diamond problem?
ASingle
BMultiple
CMultilevel
DHierarchical
Show Answer & Explanation

Correct Answer: B — Multiple

Multiple inheritance causes diamond problem when two parent classes inherit from same grandparent.

Q2.
To solve diamond problem, we use:
ASingle inheritance
BVirtual inheritance
CPublic inheritance
DProtected inheritance
Show Answer & Explanation

Correct Answer: B — Virtual inheritance

Virtual inheritance ensures only one copy of base class members.

Q3.
In public inheritance, public members of base become:
APrivate in derived
BProtected in derived
CPublic in derived
DNot inherited
Show Answer & Explanation

Correct Answer: C — Public in derived

In public inheritance, public members remain public in derived class.

Q4.
In private inheritance, public members of base become:
APrivate in derived
BProtected in derived
CPublic in derived
DNot accessible
Show Answer & Explanation

Correct Answer: A — Private in derived

In private inheritance, public members become private in derived class.

Q5.
Constructor of base class is called:
AAfter derived constructor
BBefore derived constructor
CNever
DOnly if virtual
Show Answer & Explanation

Correct Answer: B — Before derived constructor

Base class constructor is called first, then derived class constructor.

Q6.
Destructor is called in which order?
ABase first
BDerived first
CRandom
DSimultaneously
Show Answer & Explanation

Correct Answer: B — Derived first

Destructors are called in reverse order: derived first, then base.

Q7.
Multilevel inheritance means:
AMultiple base classes
BChain of inheritance (A→B→C)
CMultiple derived classes
DNo inheritance
Show Answer & Explanation

Correct Answer: B — Chain of inheritance (A→B→C)

Multilevel: A derives B, B derives C (chain).

Q8.
Hierarchical inheritance means:
AOne base, multiple derived
BMultiple base, one derived
CChain
DHybrid
Show Answer & Explanation

Correct Answer: A — One base, multiple derived

Hierarchical: multiple classes derive from one base class.

Q9.
Private members of base class are:
AInherited and accessible
BInherited but not accessible
CNot inherited
DAlways public
Show Answer & Explanation

Correct Answer: B — Inherited but not accessible

Private members are inherited but not directly accessible in derived class.

Q10.
Protected members in derived class (public inheritance) are:
APrivate
BProtected
CPublic
DNot inherited
Show Answer & Explanation

Correct Answer: B — Protected

Protected members remain protected in public inheritance.

Q11.
Constructor of base class is called:
AAfter derived constructor
BBefore derived constructor
CNever called
DRandomly
Show Answer & Explanation

Correct Answer: B — Before derived constructor

Base class constructor is always called first before the derived class constructor.

Q12.
Order of destructor call in inheritance:
ABase first, then derived
BDerived first, then base
COnly derived
DOnly base
Show Answer & Explanation

Correct Answer: B — Derived first, then base

Destructors are called in reverse order: derived class destructor first, then base class.

Q13.
Which keyword is used to call base class constructor explicitly?
Abase
Bsuper
CUsing member initializer list
Dparent
Show Answer & Explanation

Correct Answer: C — Using member initializer list

In C++, base class constructor is called using member initializer list: Derived() : Base() {}.

Q14.
Hybrid inheritance is:
ASingle inheritance only
BCombination of two or more types
CSame as multiple
DNot allowed in C++
Show Answer & Explanation

Correct Answer: B — Combination of two or more types

Hybrid inheritance combines multiple types of inheritance like hierarchical and multiple.

Q15.
In protected inheritance, public members of base become:
APublic
BProtected
CPrivate
DNot accessible
Show Answer & Explanation

Correct Answer: B — Protected

In protected inheritance, public members of base class become protected in derived class.

Q16.
final keyword in class declaration:
AMakes class abstract
BPrevents inheritance
CCreates singleton
DMakes all members const
Show Answer & Explanation

Correct Answer: B — Prevents inheritance

A class declared as final cannot be inherited by any other class.

Q17.
Base class pointer can point to:
AOnly base objects
BOnly derived objects
CBoth base and derived objects
DNeither
Show Answer & Explanation

Correct Answer: C — Both base and derived objects

Base class pointer can point to both base and derived class objects (upcasting).

Q18.
Which is NOT inherited by derived class?
APublic members
BProtected members
CConstructors
DStatic members
Show Answer & Explanation

Correct Answer: C — Constructors

Constructors and destructors are not inherited; derived class must define its own.

Q19.
using declaration in inheritance:
ACreates new member
BChanges access of inherited member
CDeletes member
DCreates alias
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.

Q20.
sizeof derived class includes:
AOnly derived members
BBase members + derived members
COnly base members
DNeither
Show Answer & Explanation

Correct Answer: B — Base members + derived members

Size of derived class includes size of base class members plus derived class members.