1.IN CASE OF DYNAMIC METHOD DISPATCH WHY WE USE REFERENCE
VARIABLE,WE CAN USE THE DIFFERENT DEFINED OBJECT DIRECTLY TO
ACCESS THE DATA MEMBER AND MEMBER FUNCTION OF THAT
RESPECTIVE CLASS?WHAT IS THE MAIN FUNCTION OF "REFERENCE
VARIABLE" HERE?
Answer Posted / vijay kumar
In case of dynamic method dispatch, It restricts from being used to call methods of other class. You cannot call overriden method which is not declared in reference variable class..
This is the main reason why we use reference variable here in dynamic polymorphism.
Hope i answer this question.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
How do you classify Dialog Box?
What do you mean by an object in java?
Explain the available thread states in a high-level?
What do you mean by Function Overloading in java?
Given a singly linked list, determine whether it contains a loop or not without using temporary space?
How many boolean functions are there?
What is widening and narrowing in java? Discuss with an example.
Can we have try block without catch block?
Can we extend a class with private constructor?
What is ph and buffers?
Is java util list serializable?
What about abstract classes in java?
How do you escape json?
Is minecraft 1.15 out?
What is treeset and treemap in java?