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
What is byte code and why is it important to java’s use for internet programming?
What is static import in java?
What is a stringbuilder?
What is definition and declaration?
How do you take thread dump in java?
Name some OOPS Concepts in Java?
What do you mean by a JVM?
What will be the default values of all the elements of an array defined as an instance variable?
Add a value x to array from index l to r where 0 <= l <= r <= n-1
What are disadvantages of java?
What does it mean to be immutable?
What is the difference between serial and throughput garbage collector?
What is meant by string is immutable?
Is string is a class in java?
I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?