Polymorphism vs Overriding vs Overloading

前端 未结 21 3313
北恋
北恋 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:27

    The classic example, Dogs and cats are animals, animals have the method makeNoise. I can iterate through an array of animals calling makeNoise on them and expect that they would do there respective implementation.

    The calling code does not have to know what specific animal they are.

    Thats what I think of as polymorphism.

提交回复
热议问题