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 abstraction in oops?
Why is there no multiple inheritance?
What are the benefits of interface?
What is abstraction with example?
Which method cannot be overridden?
What is a class in oop?
Describe these concepts: Polymorphism, Inheritance and Abstraction.
Why do we use inheritance?
What are the three parts of a simple empty class?
Which language is pure oop?
What is persistence in oop?
What is pointer in oop?
What is the renewal class?
can inline function declare in private part of class?
What are constructors in oop?