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

Can we override private constructor in java?

708


How variables are declared?

722


What is the difference between delete and delete[]

893


What is a copy constructor in java?

806


What are the benefits of operations?

697


how to create daemon thread in java?

824


Is java a virus?

715


Difference between string, stringbuffer and stringbuilder?

799


What are the different types of constructor?

702


What is the difference between error and an exception?

759


What is private protected in java?

777


What is dynamic array in java?

733


What is the difference between conversation & casting?

770


Can we call thread start () twice?

699


What is tcp and udp?

773