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 abstract class in oop?
Can private class be inherited?
Why multiple inheritance is not allowed?
String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?
what are the different types of qualifier in java?
What is meant by multiple inheritance?
Write a c++ program to display pass and fail for three student using static member function
What is abstraction with example?
is there any choice in opting subjects like 4 out of 7
What is oops with example?
What is polymorphism what are the different types of polymorphism?
What is object-oriented programming? Webopedia definition
What is a null tree?
What is polymorphism programming?
What is inheritance in oop?