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:
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 v of the type Try points to the Test object t1.
- Pass Master CIW Enterprise Developer in first attampt.
- Become SUN SCBCD certified.
- Download practice question and study guide for scdjws for exam.
- Download practice question and study guide for scja for exam.
- Get certified in first attempt download scjp - SCJP simulation.
- Get certified in first attempt download scjp-5-0 - SCJP 5/6 simulation.
- Become SUN SCMAD certified.
- Click here to get free scwcd SCWCD exam practice questions.
- Best exam simulation SUN CX310-019 download free trial.
- Become SUN Java 5.0 certified.
- Click here to get free CX310-065 SCJP 6.0 exam practice questions.
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
