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
Why parameters should be passed by reference?
What one should take care of, while serializing the object?
What is %d in printf?
What is the type of lambda expression?
What initialize variables?
What is math exp in java?
Why is it called boolean?
What methodology can be utilized to link to a database?
What is the difference between menuitem and checkboxmenu item?
How do you reverse sort in java?
What is ph and buffers?
Why generics are used in java?
What is java in detail?
What are void pointers?
write a program that list all permutations of ABCDEF in which A appears before B?