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 do you mean by platform independence?
Is finalize() similar to a destructor?
Can private method static?
Can static method access instance variables ?
Does the order of public and static declaration matter in main method?
What are peerless components in java programming?
What do you understand by overloading and overriding in java?
What are the properties of thread?
What is a java developer salary?
What about main() method in java ?
Is string is a class in java?
what is anonymous class in java?
What is a boolean output?
How is hashset defined in java?
What is a method type?