There are three classes A,B & C. All the three classes have a method called m(). I have to call the method m() from A, B or C according to the argument .For eg. if the argument is int it should call the method m() from class A. If it is char it should call m() from B. if it is string, it should call m() from C. At the same time the caller should not be aware which m() we are calling. What is the solution.

Questions by Rajseek

Showing Answers 1 - 2 of 2 Answers

See i think what u want can be solved by the concept of Dynamic method dispatch concept. Acc to this conceptclasses has methods with same name and signature.however which method will be executed wil be decided durig executio time.I hop this answers ur question.

  Was this answer useful?  Yes

prakash patel

  • Feb 11th, 2006
 

hi friend , calling method through passing object then it casting in formal paramter

e.g  m(object obj) then cast is this object type in formal parameter.

         

  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