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
What is the difference between Array and Hash Table?
What is the main use of generics in java?
what is thread in Java ?
What is set string?
What is the purpose of static methods and static variables?
How do you create a sop?
When can we say that threads are not lightweight process in java?
Name the components that are termed to be Heavy-weight component but available in Light-weight components?
A person says that he compiled a java class successfully without even having a main method in it? Is it possible?
What is the integer of 16?
Why is the singleton pattern considered to be an anti pattern?
what is a green thread? : Java thread
What is jvm? Why is java called the platform independent programming language?
Can we make constructors static?
What are the benefits of immutable objects?