Polymorphism MCQs Viva Questions

What is Polymorphism?
(A). Polymorphism means more than one function with the same tasks
(B). Polymorphism means more than one function with different tasks
(C). Polymorphism means functions with the same tasks
(D). Polymorphism means many functions in the main function with different names

Example of option (B). Polymorphism means more than one function with different tasks (Function overloading)

#include <iostream>
using namespace std;
void Sum_T4Tutorials(int a, int b)
{
  cout << "sum = " << (a + b);
}
 
void Sum_T4Tutorials(double a, double b)
{
    cout << endl << "sum = " << (a + b);
}
 
// Driver code
int main()
{
    Sum_T4Tutorials(4, 6);
    Sum_T4Tutorials(8.1, 7.4);
    return 0;
}

What is Operator overloading? 

(A). defining additional tasks to operators without changing their actual meaning
(B). defining additional tasks to operators by changing their actual meaning
(C). to discourage the operator to work according to its actual meaning
(D). None of these

Example of the option (A). defining additional tasks to operators without changing their actual meaning

Polymorphism MCQs Viva Questions
Polymorphism MCQs Viva Questions

A new definition to base class function in the derived class with the same signatures is called ______?

(A). Function overloading
(B). Function overriding
(C). Friend Function
(D). None of these

Example of option (B). Function overriding

Function Overriding C++


Which is the example of compile time Polymorphism?
(A). Function Overloading
(B). Operator Overloading
(C). A and B 
(D). Function overriding


Which is the example of run time Polymorphism?
(A). Function Overloading
(B). Operator Overloading
(C). Function overriding
(D). B and C


How more than one function can be implemented in Polymorphism?
(A). two functions in the same class
(B). two functions in the different class
(C). one function in parent and one in child class
(D). All of these

Example of the option (A). two functions in the same class

#include <iostream>
using namespace std;
class T4Tutorials {
public:
    int sum(int X,int Y)   // Function with parameter 
    {
        return X+Y;     // this function is performing sumition of  two Integer value
    }
    int sum() {              // Function with same name but without parameter
        string first= "Welcome to";
        string second="T4Tutorials.com";   // in this function concatenation is performed
       string Concated= first+second;
       cout<<Concated<<endl;
        
    }
};
int main(void) {
    T4Tutorials object;   // Object is created  
    cout<<object.sum(7, 3)<<endl; //first method is called
    object.sum();  // second method is called
    return 0;
}

Example of option (B). two functions in a different class, (C). tone function in parent and one in child class

#include <iostream>
using namespace std;
// Base class
class Zoo_Animals {
  public:
    void Zoo_AnimalsSound() {
    cout << "The Zoo_Animals makes a sound "<<endl; ;
  }
};

// Derived class
class cat : public Zoo_Animals {
  public:
    void Zoo_AnimalsSound() {
    cout << "The cat: meows "<<endl; ;
   }
};

// Derived class
class peacock : public Zoo_Animals {
  public:
    void Zoo_AnimalsSound() {
    cout << "The peacock: scream "<<endl; ;
  }
};

int main() {
  Zoo_Animals myZoo_Animals;
  cat mycat;
  peacock mypeacock;

  myZoo_Animals.Zoo_AnimalsSound();
  mycat.Zoo_AnimalsSound();
  mypeacock.Zoo_AnimalsSound();
  return 0;
}

Which of the following can have Polymorphism?
(A). Only functions
(B). only operators
(C). both functions and operators
(D). None of these

Example of the option (A).  Functions Polymorphism

#include <iostream>
using namespace std;
class T4Tutorials {
public:
    int sum(int X,int Y)   // Function with parameter 
    {
        return X+Y;     // this function is performing sumition of  two Integer value
    }
    int sum() {              // Function with same name but without parameter
        string first= "Welcome to";
        string second="T4Tutorials.com";   // in this function concatenation is performed
       string Concated= first+second;
       cout<<Concated<<endl;
        
    }
};
int main(void) {
    T4Tutorials object;   // Object is created  
    cout<<object.sum(7, 3)<<endl; //first method is called
    object.sum();  // second method is called
    return 0;
}

 

Example of option (B).  operators Polymorphism
Greater than Operator Overloading C++


Important table for viva questions & MCQs

Early binding late binging
Order of Execution: 1st(Early binding) then 2nd (late binging)
static binging Dynamic Binding
Compile-time Run time polymorphism
Matching of a function call with function definition is performed at compiler time. Matching of a function call with function definition is performed at run time.
Full information about function calling and matching with function definition  is visible to the compiler during compile time Full information about function calling and matching with function definition is not visible to the compiler during compile time but it’s visible during run time.
More  efficient: because the compiler already has knowledge that what code will execute More flexible:

 

Fast execution Slow execution
Examples: Function overloading and operator overloading Examples: Virtual functions

More MCQs on Polymorphism

  1. Polymorphism MCQs SET 1

  2. Virtual Function MCQs
  3. Operator Overloading MCQs
  4. Early binding and Late Binding in C++

Programming C Plus Plus MCQs Homepage

shamil memory table

Computer Science Repeated MCQs Book Download

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.