Dynamic method Dispatch

What is dynamic method dispatch?

Questions by ganesh_tot

Showing Answers 1 - 13 of 13 Answers

This is a unique feature in JAVA.as the name itself suggests that it is related with run time.In this classes has methods with same method name and signature.However which method will b executed will be decided during run time.

  Was this answer useful?  Yes

salil.kaul

  • Apr 11th, 2006
 

Consider this piece of code: 2 classes one derived from another with methods named "method" with same name and signatureclass base

Code
  1. span style="color: #0000ff;">"I am in base methodn""I am in derived methodn"// Reference to base class    

  2. // Now point the reference to object of derived    

  3. // calls derived overridden method because object pointed is of type derived

  4. }

  5. Output:I am in base method I am in derived method

  6.  

  Was this answer useful?  Yes

mastanreddy

  • Oct 27th, 2006
 

Hi
This is Mastan
dynamic method dispatch is run time polymorphism , superclass reference variable can refer to subclass object

Code
  1. span style="color: #0000ff;">"a"+"b"

  Was this answer useful?  Yes

Lalit

  • Nov 30th, 2006
 

Hi,

I think sub class can instantiate super class instance but can not give right to access its member.

i.e.

sum1 s=new sum2();

s.m1();// OK

s.m2();// Not rigjht because m2 is a member of sum2 class . If i am wrong then please give clerification

Thanks

  Was this answer useful?  Yes

pranab mohanty

  • Feb 12th, 2007
 

Dynamic method dispatch is a technique by which a call to a overridden method is solved at runtime rather than compile time..this is how java implements runtime polymorphism.

  Was this answer useful?  Yes

srinu.p

  • Apr 24th, 2008
 

Hi
My name is srinivas.Iam very much confused about DYNAMIC METHOD DISPATCH.
Can any one help me with a clear example.

  Was this answer useful?  Yes

Dynamic method dispatch is run time polymorphism/late binding. When you override a super class method in subclass, the method which is to be  executed is decided at the run time rather than at the compile time.

  Was this answer useful?  Yes

Dynamic method dispatch is the mechanism by which a call to an overridden method is resolved at run time, rather than compile time. Dynamic method dispatch is important because this is how Java implements run-time polymorphism.

  Was this answer useful?  Yes

arun

  • Dec 29th, 2011
 

According to my view in dynamic method dispatching both super class and sub class have same method so in this method in super class dispatches, base class method executed than super class method executed.

  Was this answer useful?  Yes

Shahhid Hussain

  • Jan 2nd, 2012
 

Code
  1. span style="color: #0000ff;">"Inside As callme method""Inside Bs callme method""Inside Cs callme method"// object of type A

  2. // object of type B

  3. // object of type C

  4.     A r; // obtain a reference of type A

  5.  

  6.     r = a; // r refers to an A object

  7.     r.callme(); // calls As version of callme

  8.  

  9.     r = b; // r refers to a B object

  10.     r.callme(); // calls Bs version of callme

  11.  

  12.     r = c; // r refers to a C object

  13.     r.callme(); // calls Cs version of callme

  14.   }

  15. }

  Was this answer useful?  Yes

Bismay kumar Biswal

  • Feb 29th, 2012
 

Dynamic dispatch method is achieved through run time polymorphism.when a method of base class is being overridden by their corresponding child class,the object of that class make the call to their corresponding and it is decided at the run time when object is created though it may be referenced by base class variable

  Was this answer useful?  Yes

saroj kumar

  • Apr 9th, 2012
 

Hi,
The process of assigning sub class object to super class reference variable is called as Dynamic Dispatch.

Consider the following classes,

Code
  1.  

  Was this answer useful?  Yes

zeeshan

  • Jun 12th, 2012
 


Hi Friend,

In dynamic method dispatch,super class refers to subclass object and implements method overriding.

Code
  1. span style="color: #0000ff;">"A Beautiful flower.""Rose""Lotus."

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions