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
Explain an intermediate language?
Is null a keyword in java?
Can array grow dynamically in java?
Why charat is used in java?
Can a abstract class be declared final?
Does it matter in what order catch statements for filenotfoundexception and ioexception are written?
What are different exception types exceptions available in java ?
What is the symbol for line break?
Give the difference between the println method and sqrt method?
What are features of java?
What are structs in java?
What is a function in java?
What is the final keyword?
What is an accessor?
Explain the selection sort algorithm?