Practice 20 Polymorphism 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 — Function overloading
Function overloading is resolved at compile time (static polymorphism).
Show Answer & Explanation
Correct Answer: C — Virtual functions
Virtual functions enable runtime polymorphism through dynamic binding.
Show Answer & Explanation
Correct Answer: B — virtual void f() = 0
Pure virtual function is declared with = 0.
Show Answer & Explanation
Correct Answer: B — At least one pure virtual function
A class with at least one pure virtual function is abstract.
Show Answer & Explanation
Correct Answer: B — Only inherited
Abstract classes cannot be instantiated, only inherited.
Show Answer & Explanation
Correct Answer: C — Parameter list
Overloading is resolved by different parameter list (number/type).
Show Answer & Explanation
Correct Answer: B — ::
Scope resolution operator (::) cannot be overloaded.
Show Answer & Explanation
Correct Answer: C — Using base pointer to delete derived object
Virtual destructor ensures proper cleanup when deleting via base pointer.
Show Answer & Explanation
Correct Answer: B — Classes with virtual functions
Virtual pointer (vptr) is created for classes with virtual functions.
Show Answer & Explanation
Correct Answer: B — Runtime
Late binding (dynamic binding) occurs at runtime.
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.
Show Answer & Explanation
Correct Answer: B — Function overrides base virtual function
override keyword ensures the function actually overrides a base class virtual function.
Show Answer & Explanation
Correct Answer: B — Prevents further overriding
A virtual function marked final cannot be overridden in further derived classes.
Show Answer & Explanation
Correct Answer: B — Safe downcasting with runtime check
dynamic_cast performs safe downcasting with runtime type checking for polymorphic types.
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.
Show Answer & Explanation
Correct Answer: B — Type information at runtime
typeid returns type_info object containing runtime type information.
Show Answer & Explanation
Correct Answer: B — Overriding function can return derived type
Covariant return allows overriding function to return pointer/reference to derived class.
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.
Show Answer & Explanation
Correct Answer: A — Runtime Type Information
RTTI (Runtime Type Information) provides type information at runtime using typeid and dynamic_cast.
Show Answer & Explanation
Correct Answer: B — Calls current class version only
Virtual functions in constructor/destructor call current class version, not derived class.