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
Write a function for palindrome and factorial and explain?
What is a dot notation?
What is jit compiler in java?
How to display all the prime numbers between 1 and 100
Differentiate between the constructors and methods in java?
What is difference between next () and nextline () in java?
Why can we not override static method?
How many arguments can be passed to main ()?
What is arrays sort in java?
What is classes in java?
Is null a string in java?
how to one war file class to another war file class?
What is the point of java?
What is widening and narrowing in java? Discuss with an example.
What are Normalization Rules? Define Normalization?