In Table 7 the same code given in Table 1 is presented except that the function1 method is now a class method with the calling object passed in as the second argument. Table 8 show the necessary changes that need to be made to the application calls given the revised version of ClassOne presented in Table 7. The answer is that it does not know. The decission as to which function1 is to be used is left till run time using a technique called Dynamuc method lookup . Polymorohism is thus a way of giving a method one name that is shared up and down a class hierarchy, with each class in the hierarchy implementing the method in a way appropriate to itself.
Polymorphism only applies to specific sets of methods.
The callses musr support the same set of required methods. Note also that dynamic method lookup is not required for static or private methods as these must called in relation to a class or an instance respectively. Created and maintained by Frans Coenen .