Polymorphism vs Overriding vs Overloading

前端 未结 21 3191
北恋
北恋 2020-11-22 01:10

In terms of Java, when someone asks:

what is polymorphism?

Would overloading or overriding be

21条回答
  •  不知归路
    2020-11-22 01:33

    overloading is when you define 2 methods with the same name but different parameters

    overriding is where you change the behavior of the base class via a function with the same name in a subclass.

    So Polymorphism is related to overriding but not really overloading.

    However if someone gave me a simple answer of "overriding" for the question "What is polymorphism?" I would ask for further explanation.

提交回复
热议问题