Computer Science, asked by vikash2506, 1 year ago

What is polymorphism? what are there categories? explain with an example regarding function overloading?

Answers

Answered by Sushil4002
0
In programming languages and type theory, polymorphism (from Greek πολύς, polys, "many, much" and μορφή, morphē, "form, shape") is the provision of a single interfaceto entities of different types.[1] A polymorphic type is one whose operations can also be applied to values of some other type, or types.[2] There are several fundamentally different kinds of polymorphism:

Ad hoc polymorphism: when a function has different implementations depending on a limited range of individually specified types and combinations. Ad hoc polymorphism is supported in many languages using function overloading.Parametric polymorphism: when code is written without mention of any specific type and thus can be used transparently with any number of new types. In the object-oriented programming community, this is often known as generics or generic programming. In the functional programming community, this is often shortened to polymorphism.Subtyping (also called subtype polymorphism or inclusion polymorphism): when a name denotes instances of many different classes related by some common superclass.[3]

The interaction between parametric polymorphism and subtyping leads to the concepts of variance and bounded quantification.

Similar questions