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 the point of oop?
Can we override main method?
Advantage and disadvantage of routing in telecom sector
Can destructor be overloaded?
Whats oop mean?
What are properties in oop?
what is difference between class template and template class?
What is multilevel inheritance explain with example?
What is object and example?
Is abstract thinking intelligence?
How do you achieve polymorphism?
What is advantage of inheritance?
What is oops?what is its use in software engineering?
Can you inherit a private class?
What is the example of polymorphism?