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 is a class and object?
How does polymorphism work?
What is a superclass in oop?
What are benefits of oop?
Explain the advantages of inheritance.
Please send ford technologies placement paper 2 my mail id
What is destructor example?
What is polymorphism oop?
What exactly is polymorphism?
What is difference between oop and pop?
What do you mean by Encapsulation?
Which is better struts or spring?
What is the importance of oop?
What polymorphism means?
Why do while loop is used?