what is polymorphism with example?types of polymorphism?
Answer Posted / ramaraju
polymorphism means "same thing will exists with different
forms"
Ex :suppose we need to find volume of
circle,rectangle,triangle.ect in a sampe program.
genrally what we need to do is write the code volume for
cirle,rectangle,triangle in sepratly.
using polymorphism concept we simply write the volume code
with different parameter list ect
Ex:
class a {
volume(int a)//for rectangle
{
---
}
volume (int a,intb,intc)//for triangle
{
--
}
volume (string s)//for circle
{
--
}
}end of class A
polymorphisam are mainly two types
static polymorphisam(corresponding method will bind at the
time of compiling)
dynamic polymorphisam(corresponding method will bind at the
run time)
| Is This Answer Correct ? | 162 Yes | 18 No |
Post New Answer View All Answers
Difference between association, composition and aggregation?
What is method reference in java?
What is the final keyword in java?
Is an integer an object?
What purpose do the keywords final, finally, and finalize fulfill?
Define interface in java?
How to display names of all components in a Container?
What is set and get methods in java?
What happens if main method is not static?
Can we create our own daemon thread?
What is the association?
What about method local inner classes or local inner classes in java?
Can finally block be used without a catch?
Is alive in java?
What does java stand for?