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.
- Become CIW Master CIW Enterprise Developer certified.
- Best exam simulation SUN scbcd download free trial.
- Click here to get free scdjws SCDJWS exam practice questions.
- Click here to get free scja SCJA exam practice questions.
- Get certified in first attempt download scjp - SCJP simulation.
- Download free practice test for SUN SCJP 5/6 exam.
- Get certified in first attempt download scmad - SCMAD simulation.
- Click here to download scwcd test study guide and practice question.
- Pass SCJA in first attampt.
- Download practice question and study guide for CX310-055 for exam.
- Click here to get free CX310-065 SCJP 6.0 exam practice questions.