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 <> used for in java?

669


How do you compare two strings lexicographically?

537


What are class members by default?

659


is it possible to instantiate the math class?

531


What is definition and declaration?

526






Why do we need autoboxing in java?

518


Explain about the dynamic behavior of core java?

634


How big is a 32 bit integer?

526


What are multiple inheritances? Is it supported by java?

463


What is the difference between yielding and sleeping in java programming?

584


How do you compare values in java?

545


Is a case study a method or methodology?

464


Is static a singleton?

523


Can private class be inherited in java?

549


Explain the inheritance?

577