Polymorphism – C# Programming interview Questions

(Last Updated On: May 9, 2017)

C# programming interview questions and answers on polymorphism with explanation asked in technical job interview for freshers and experienced.

Topic –  Polymorphism – Method Overloading, Method Overriding and Operator Overloading, virtual.


Q – If we call the below statements in main (), what is the wings’ colour of Parrot? Give reason.

Bird b = new Parrot();
b.wings();
In case of unknown colour, complete the source code of classes to get correct colour of Parrot’s wings.

Answer:

Parrot wings’ colour will be unknown as below statement will call wings() method of the base class i.e. Bird. As base class wings() method is not virtual and not overriden in derived class to get its own implementation.

Bird b = new Parrot();

b.wings();

To get the correct parrot wings’ colour we need to declare wings() method as virtual and have to override it in derived that is Parrot class. Example and source code below –