What is polymorphism ? Explain with examples
Answer Posted / danneel
The previous example is overloading not polymorphism.
Polymorphism is multiple classes having the same method -
for example - a DOG and CAT class that are sub classes of
ANIMAL - ANIMAL has a virtual function - SPEAK. DOG
implements speak via System.out.println("WOOF") and CAT
implements it as System.out.println("MEOW") then
ANIMAL anim = null;
anim = New DOG();
anim.speak();
anim = New CAT();
anim.speak()
will each put out the appropriate string.
Is This Answer Correct ? | 18 Yes | 3 No |
Post New Answer View All Answers
What are the components of marker interface?
why reinterpret cast is considered dangerous?
What is difference between inheritance and polymorphism?
What is abstraction in oops?
What is encapsulation with real life example?
Can we override main method?
What is variable example?
hi all..i want to know oops concepts clearly can any1 explain??
Can static class have constructor?
Can a varargs method be overloaded?
How to use CMutex, CSemaphore in VC++ MFC
Write a program to sort the number with different sorts in one program ??
What is abstraction example?
what type of question are asked in thoughtworks pair programming round ?
#include