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
How do you write a good declaration?
How many types of memory areas are allocated by JVM in java?
Does isempty check for null?
Write a function to print Fibonacci series and Tribonacci series?
What is currentthread()?
What are methods and how are they defined?
Which is better ascii or unicode?
What is member in java?
What happens if an exception is throws from an object's constructor?
What is java in detail?
What is the base class for error and exception?
Does list maintain insertion order java?
What do you mean by multithreaded program?
Why do we need singleton class?
What does %4d mean in java?