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
write knight tour problem which is present in datastructure
What are the 5 oop principles?
What is the difference between abstraction and polymorphism?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
Why is oop better than procedural?
#include
What is the important feature of inheritance?
Can we create object of abstract class?
Which method cannot be overridden?
Where is pseudocode used?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
Is this job good for future? can do this job post grduate student?
What is pure oop?
What is encapsulation and abstraction? How are they implemented in C++?
What are the advantages of polymorphism?