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
What is garbage collector?
Can a class be declared as static?
How many classes can any class inherit java?
Does substring create a new object?
State the difference between creating string as new () and literal.
Explain Basics of OOP Language in java
Is there any difference between synchronized methods and synchronized statements?
What is main difference between variable and constant?
Can a class extend 2 classes in java?
How many inner classes can a class have?
How are this() and super() used with constructors in java programming?
Can you override private or static method in java?
EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.
How many arguments can be passed to main ()?
What is struts in java?