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


Please Help Members By Posting Answers For Below Questions

What is the final field modifier?

540


How do you do absolute value in java?

521


How do you sort a string in alphabetical order in java?

525


What is the difference between checked exception and unchecked exception?

522


Explain hashset and its features?

572






Is it possible to use Semaphore/ Mutex in an Interrupt Handler?

530


Why parsing is done?

500


How we can make copy of a java object?

646


What do you understand by the term string pool?

559


What is the use of inner class?

541


How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?

536


What is the size of int in 64-bit jvm?

547


Is array serializable java?

515


What is the difference between stringbuffer and stringbuilder?

572


Write a java program to check if a number is prime or not?

532