Method overloading and method overriding

Method overloading @Overload

  • The same method name
  • Method of parameter type, number, sequence, at least one different
  • The return value may not be the same type
  • The method may not be the same modifier

Method overloading @Override

  • Covering only exist (including parent and parent profile) subclasses and superclasses between. In the same class can be overridden methods can not be overridden
  • Subclass name, return type and signature parameters must be the name of the parent class method, signature and return type parameters consistent
  • Subclass method can not be reduced access to the parent class method
  • Subclass method can not throw more parent class for exception
  • Parent class static methods can not be overridden by subclasses non-static method
  • Subclasses can be defined as static methods with the same name as the parent class static method, a static method in order to hide the parent class in subclasses
  • Private methods of the parent class can not be covered
  • Method abstract parent class can be subclassed to cover in two ways:
  1. Subclasses implement the abstract parent class method
  2. Abstract subclass re-statement of the parent class
  • The method of non-abstract parent class can be overridden abstract method

 

Guess you like

Origin www.cnblogs.com/luminous-Xin/p/10963661.html