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

Explain about strings in java?

624


Why should we use singleton pattern instead of static class?

466


Can you explain the usages of class.forname()?

613


when a request is generated from apache tomcat 5.5 and goes to oracle 10g or mysql,,, how the oracle or mysql reads the request as apache is a web server and oracle 10g is application server? when the oracle 10g provides response, how the apche tomcat reads it???

1679


Is there any case when finally will not be executed?

527






What are the types of strings?

570


What is assembly language?

554


Can a class declared as private be accessed outside it’s package?

517


What does those terms actually mean included in the j.d.k i.6?

1608


What is the public method modifier?

550


which class is the wait() method defined in? : Java thread

525


What is the difference between delete and delete[]

586


Describe method overriding

589


How are java objects passed to a method and what are native methods?

604


How variables are stored in memory?

541