Polymorphism (Cont.)


Runtime Polymorphism (or Dynamic Method Dispatch)
Runtime polymorphism is the mechanism by which a call to an overridden method is resolved at run time, rather than compile time.
Therefore, if a superclass contains a method that is overridden by a subclass, then when different types of objects are referred to through a superclass reference variable, different versions of the method are executed.

Advantages of Runtime Polymorphism


      A man is struggling to find a parking space.    
      “Lord,” he prays. “I can’t stand this. If you open a space up for me,    
      I swear I’ll give up the drink and go to mass every Sunday.”    
      Suddenly, the clouds part and the sun shines on an empty parking spot.    
      Without hesitation, the man says: “Never mind, I found one!”