Polymorphism - Object oriented programming (MCQ) questions

Here, you can read Polymorphism multiple choice questions and answers with explanation.

1)   Which property of Object Oriented Programming is exhibited by the code:

#include< iostream>
class quest
float add( float a, float b)
cout << “The sum is:”;
reurn(a+b); } }
int add( int a, int b, int c)
cout << ”The sum is:”;

int add( int a, int b=0)
cout << ”The sum is:”;
int main( )

quest q
q. add( 50.5, 48.2)
q. add( 42, 56, 82)
q. add( 23)
return 0;

- Published on 19 Oct 15

a. Compile time polymorphism
b. Run time polymorphism
c. Both
d. none
Answer  Explanation 

ANSWER: Compile time polymorphism

The property of function overloading is also known as Compile time polymorphism. Here in this code we see how a function is overloaded using different datatype, different number of arguments and default argument. Function overloading is a concept which allows the use of same function name to different functions for performing same or different task in the same class.