0

As I understand, dynamic polymorphism allows for overriding methods with different returns, so that inheritances can lead to varying responses based on the subclass. Such as explained in Prabhakar Manthena’s question. According to Cay Horstmann’s Object-Oriented Design & Patterns, this leads to runtime polymorphism having greater flexibility than static polymorphism when implementing function calls.

However, I understand it as two different function altogether, with runtime polymorphism being useful when inherited methods need to be updated for subclasses, and static polymorphism being useful when a class needs to account for many ways of calling a method. How then would one type of polymorphism be, in general, more flexible than the other. Can anyone show an example that briefly shows how dynamic polymorphism can allow for greater flexibility when writing in Java?

  • Your understanding of what is dynamic polymorphism is wrong, see the dup for more info. – Nir Alfasi Nov 30 '17 at 20:53
  • 1
    I think this is a question of definitions, first and foremost. Typically in the context of Java, one would interpret "runtime/dynamic polymorphism" as referring to method overrides, and "static polymorphism" as referring to method overloads. Are we on the same page in terms of our definitions? – Oliver Charlesworth Nov 30 '17 at 20:53

0 Answers0