Machine-translated by Google. Questions are authored in English.
Top

Polymorphism and Virtual Functions Questions and Answers

11.

Which of the following would successfully overload the method void calculate(int a, double b) ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: B

The successful overload is void calculate(double b, int a).

An overloaded method must differ in its parameter list: the number, the types, or the order of the types. calculate(double, int) has the parameter types in a different order from calculate(int, double), so it is a distinct signature and a valid overload.

Changing only the return type (int calculate(int x, double y)) is not enough, nor is renaming the parameters (calculate(int b, doubie a), where 'doubie' is evidently a misprint for double, has the same types), nor is adding static, since modifiers are not part of the signature. All three would clash with the original method.

Please log in or register to report this question.

12.

Which of the following correctly defines runtime polymorphism in C++ ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: D

Runtime polymorphism in C++ comes from virtual functions and overriding.

When a base class declares a function virtual and a derived class overrides it, a call made through a base class pointer or reference is resolved while the program runs, using the actual type of the object (dynamic binding through the virtual table). That is runtime polymorphism.

Function overloading, operator overloading and templates are all resolved by the compiler, so they are forms of compile-time (static) polymorphism.

Please log in or register to report this question.

13.

The following feature of C++ is an example of run time polymorphism

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: D

Run time polymorphism comes from a VIRTUAL FUNCTION.

When a base class declares a function virtual and a derived class overrides it, a call through a base-class pointer or reference is bound at run time, through the virtual table, to the version for the object's actual type. This dynamic binding is run time polymorphism.

Operator overloading and templates are resolved by the compiler, so they are compile time polymorphism. Pointers are a language feature that virtual calls use, not a form of polymorphism themselves.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Polymorphism and Virtual Functions Questions and Answers || Polymorphism and Virtual Functions MCQ Questions and Answers || Polymorphism and Virtual Functions GK Questions and Answers || Polymorphism and Virtual Functions GK MCQ Questions || Polymorphism and Virtual Functions Multiple Choice Questions and Answers || Polymorphism and Virtual Functions GK || GK on Polymorphism and Virtual Functions || Object Oriented Programming Questions and Answers || Object Oriented Programming MCQ Questions and Answers || Object Oriented Programming GK Questions and Answers || GK on Object Oriented Programming