what is polymorphism with example?types of polymorphism?
Answer Posted / hassan arafat
Polymorphism allows an entity (for example, variable,
function or object) to take a variety of representations.
Ad-hoc polymorphism: This polymorphism let a function to
have different implementations based on its parameters and
return type. Ad-hoc polymorphism is supported through
function and method overloading.
Parametric polymorphism: lets you write a piece of code
that is not associated with a particular type and therefore
can be used with any type. Object oriented languages like
C# achieve it through generics.
Inclusion polymorphism: let a type hold instances of many
different types as long as the types are related by some
common parent class. Object oriented languages like C#
achieve inclusion polymorphism through inheritance.
| Is This Answer Correct ? | 33 Yes | 11 No |
Post New Answer View All Answers
Why use string handling in Java?
what is comparable and comparator interface?
Is a class an object?
What happens if an exception is throws from an object's destructor?
Why are constructors used?
How is the marker interface used in Java?
What are the 3 types of control structures?
Why string is a class?
What are keywords in programming?
Compare java and python.
Explain about java sdk?
What is object english?
What is scope of a variable?
Differentiate between stringbuffer and stringbuilder in java.
Is java good for beginners?