overloading and overriding

What is the difference between method overloading and method overriding in Java?

Differences between method overloading and overriding are:

  • Method overloading is static polymorphism. Method overriding is runtime polymorphism.
  • Method overloading occurs within the same class. Method overriding happens in two classes with hierarchy relationship.
  • Parameters must be different in method overloading. Parameters must be same in method overriding.
  • Method overloading is a compile time concept. Method overriding is a runtime concept.

猜你喜欢

转载自www.cnblogs.com/longchang/p/10648293.html