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
Which language is pure oop?
write a program to find 2 power of a 5digit number with out using big int and exponent ?
given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy
How do you explain polymorphism?
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
What is class and example?
What is encapsulation in oop?
What is polymorphism explain?
What is pointer in oop?
What are the 4 main oop principles?
Explain the concepts involved in Object Oriented programming.
explain sub-type and sub class? atleast u have differ it into 4 points?
#include
What is encapsulation and abstraction? How are they implemented in C++?
What is class in oop with example?