OOP with C++

Polymorphism — Practice MCQs for CCAT

20 Questions Section B: Programming OOP with C++

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

Q1.
Compile-time polymorphism is achieved by:
AVirtual functions
BFunction overloading
CDynamic binding
DBase class pointer
Show Answer & Explanation

Correct Answer: B — Function overloading

Function overloading is resolved at compile time (static polymorphism).

Q2.
Runtime polymorphism requires:
AFunction overloading
BOperator overloading
CVirtual functions
DStatic functions
Show Answer & Explanation

Correct Answer: C — Virtual functions

Virtual functions enable runtime polymorphism through dynamic binding.

Q3.
Pure virtual function syntax:
Avirtual void f()
Bvirtual void f() = 0
Cvoid f() = 0
Dpure virtual void f()
Show Answer & Explanation

Correct Answer: B — virtual void f() = 0

Pure virtual function is declared with = 0.

Q4.
Abstract class has:
ANo functions
BAt least one pure virtual function
COnly static functions
DNo data members
Show Answer & Explanation

Correct Answer: B — At least one pure virtual function

A class with at least one pure virtual function is abstract.

Q5.
Abstract class can be:
AInstantiated
BOnly inherited
CDestroyed
DCopied
Show Answer & Explanation

Correct Answer: B — Only inherited

Abstract classes cannot be instantiated, only inherited.

Q6.
Function overloading is based on:
AReturn type only
BFunction name only
CParameter list
DAccess specifier
Show Answer & Explanation

Correct Answer: C — Parameter list

Overloading is resolved by different parameter list (number/type).

Q7.
Operator overloading cannot overload:
A+
B::
C<<
D[]
Show Answer & Explanation

Correct Answer: B — ::

Scope resolution operator (::) cannot be overloaded.

Q8.
Virtual destructor is needed when:
AAlways
BNever
CUsing base pointer to delete derived object
DOnly with multiple inheritance
Show Answer & Explanation

Correct Answer: C — Using base pointer to delete derived object

Virtual destructor ensures proper cleanup when deleting via base pointer.

Q9.
vptr is created for:
AEvery class
BClasses with virtual functions
CStatic classes
DFriend classes
Show Answer & Explanation

Correct Answer: B — Classes with virtual functions

Virtual pointer (vptr) is created for classes with virtual functions.

Q10.
Late binding occurs at:
ACompile time
BRuntime
CLink time
DLoad time
Show Answer & Explanation

Correct Answer: B — Runtime

Late binding (dynamic binding) occurs at runtime.

Q11.
What is operator overloading?
ADefining new operators
BGiving operators new meaning for user types
CRemoving operators
DChanging operator precedence
Show Answer & Explanation

Correct Answer: B — Giving operators new meaning for user types

Operator overloading allows giving special meaning to operators for user-defined types.

Q12.
override keyword ensures:
AFunction is new
BFunction overrides base virtual function
CFunction is static
DFunction is inline
Show Answer & Explanation

Correct Answer: B — Function overrides base virtual function

override keyword ensures the function actually overrides a base class virtual function.

Q13.
final keyword on virtual function:
AMakes it pure virtual
BPrevents further overriding
CMakes it static
DRemoves from vtable
Show Answer & Explanation

Correct Answer: B — Prevents further overriding

A virtual function marked final cannot be overridden in further derived classes.

Q14.
Dynamic_cast is used for:
AStatic type conversion
BSafe downcasting with runtime check
CRemoving const
DBit-level casting
Show Answer & Explanation

Correct Answer: B — Safe downcasting with runtime check

dynamic_cast performs safe downcasting with runtime type checking for polymorphic types.

Q15.
Size overhead of virtual function:
ANo overhead
BOne vptr per object
COne pointer per function
DDoubles class size
Show Answer & Explanation

Correct Answer: B — One vptr per object

Each object of a class with virtual functions has one vptr pointing to the vtable.

Q16.
typeid operator returns:
AObject size
BType information at runtime
CObject address
DCompilation error
Show Answer & Explanation

Correct Answer: B — Type information at runtime

typeid returns type_info object containing runtime type information.

Q17.
Covariant return type means:
ASame return type always
BOverriding function can return derived type
CNo return value
DMultiple return types
Show Answer & Explanation

Correct Answer: B — Overriding function can return derived type

Covariant return allows overriding function to return pointer/reference to derived class.

Q18.
Function hiding occurs when:
AVirtual function is overridden
BDerived function has same name but different signature
CFunction is private
DFunction is static
Show Answer & Explanation

Correct Answer: B — Derived function has same name but different signature

Function hiding happens when derived class has same function name but different parameters.

Q19.
RTTI stands for:
ARuntime Type Information
BReal Time Type Interface
CReturn Type Type Info
DReference To Type Instance
Show Answer & Explanation

Correct Answer: A — Runtime Type Information

RTTI (Runtime Type Information) provides type information at runtime using typeid and dynamic_cast.

Q20.
Virtual function in constructor:
AWorks polymorphically
BCalls current class version only
CCauses error
DNot allowed
Show Answer & Explanation

Correct Answer: B — Calls current class version only

Virtual functions in constructor/destructor call current class version, not derived class.