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 final field modifier?
How do you do absolute value in java?
How do you sort a string in alphabetical order in java?
What is the difference between checked exception and unchecked exception?
Explain hashset and its features?
Is it possible to use Semaphore/ Mutex in an Interrupt Handler?
Why parsing is done?
How we can make copy of a java object?
What do you understand by the term string pool?
What is the use of inner class?
How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?
What is the size of int in 64-bit jvm?
Is array serializable java?
What is the difference between stringbuffer and stringbuilder?
Write a java program to check if a number is prime or not?