You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .

hi this is pavan new to his group and I have justcompleted my MCA and looking for opening.I attended for 3 interviews the common question they asked iswhat is the use of polymorphism?give one suitable realtime example?

Well this disappoints me . . .
You have a masters in computer science or computer applications yet you aren't sure of a suitable answer for polymorphism???

Well . . . I will help you out.

Polymorphism is one of the most important and most valuable concepts of programming.
Polymorphism literally means "many forms".
which means the data can be represented in multiple forms.
Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior.
Polymorphism is a concept linked to inheritance and assures that derived classes have the same functions even though each derived class performs different operations.
An example would be if you had a class animal
all animals comunicate in some form just i different ways so you would have an abstract function declared in the parent class talk()
This function will now use polymorphism by example of a dog the dog would inherit this function talk but the dogs talk() function would be different.
animal.talk()
{
cout << "spoke";
}
dog.talk()
{
cout << "bark";
}
I hope this helps you but I am kinda upset of course your subject is kinda generalized I don't think a master of computer science should be getting advice on how to pass an interview from an 17 year old high school student. Sorry if this is rude but its just my opinion and doesn't matter right?