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 difference between word and integer?
Explain the importance of throwable class and its methods?
Can we override the static methods?
What is an inner class in java?
What is the Concept of Encapsulation in OOPS
How to find the index of the largest number in an arraylist java?
Can we clone singleton object?
Explain the overview of UDP messaging.
What is meant by vector class, dictionary class, hash table class, and property class?
What is a singleton class? Give a practical example of its usage.
What are constants and how to create constants in java?
What is the syntax and characteristics of a lambda expression?
How can you avoid serialization in child class if the base class is implementing the serializable interface?
When should you make a function static?
Differences between traditional programming language and object oriented programming language?