What is runtime polymorphism or dynamic method dispatch?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is runtime polymorphism or dynamic method dispatch?

Rating:

In Java, runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass. The determination of the method to be called is based on the object being referred to by the reference variable. For example:

class Try    {
      void disp()   {}
}

class Test extends Try    {
      void disp()   {}
      public static void main(String args[]){
         Try t=new Try();
         Test t1=new Test();
         Try v;
         v=t1;
         v.disp();
// call to the disp() method from Test.
      }
}


Here, the Test version of the disp() method is called because the reference variable r of the type Try points to the Test object t1.


Rating:



Other articles

Click here to Article home

MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD, SCJA, SCBCD, SCMAD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.
 
HACKER SAFE certified sites prevent over 99.9% of hacker crime.