Answer Posted / jamia hamdard
Dynamic method dispatch is polymorphism!
we create object dynamically like:
animal ani = new animal();
If there are two different classes 'dog' and 'horse' that inherit from the class 'animal', then we can assign the 'object' of these two classes to the reference variable 'ani' made above. like:-
animal ani = new dog();//since dog inherits from animal.
or
animal ani2 = new horse();//since horse inherits from animal.
polymorphism is same name and having different signatures like 'dog' and 'horse' both are animals.
Its use is to make polymorphic arrays which stores Objects of different classes. The type of the array is that of the 'super class' which is 'animal' here.
thanks!!
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
Can we make constructors static?
What is boolean query?
Is map ordered in java?
Is int primitive data type?
What is super in java?
What is empty string literal in java?
What is a Null object?
What is meant by null and void?
Write a program to find the whether a number is an Armstrong number or not?
How many bytes is a string in java?
What is integers and example?
What all access modifiers are allowed for top class ?
What is method overriding in java ?
Can we define static methods inside interface?
How we can skip finally block of exception even if some exception occurs in the exception block in java?