OverRiding Vs PolyMorphism

后端 未结 4 2282
醉梦人生
醉梦人生 2020-12-29 10:29

What is the difference between the two?

A super class having myMethod(int a) and an inheriting class having the same method, Is this overriding or poly

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 11:26

    I am doing my software architecture exam tomorrow, and this is what i have understood from my reading.

    Polymorphism is a concept of object oriented programming that allows a field, in this case, an object, to be changed from one form to another. Poly = multiple, morph = change.

    Overriding a method, is essentially a dynamic binding of a method which allows a method to be changed during run-time. It is a form of polymorphism since a method's functionality gets changed over the course of time.

    I took some of my facts from here - https://beginnersbook.com/2013/03/polymorphism-in-java/

提交回复
热议问题