Java overload conditions and methods were covered to be met

1. Overload: follow the "two with three different"

With two: with the same method on a class

Three different: different parameter types, the number, order

special reminder:

  • The return value can not be a different configuration method overloading
  • Parameter name constitute different method overloading

2. Overwrite (overwrite) requirements

  1. Name of the child class method, the return type must match the parent class.
  2. Subclass method can not be reduced access to the parent class method
  3. Subclass method can not throw more of an exception than the parent class method
  4. The method of covering exists only in the parent class and subclass, the method of the same class can be overridden
  5. Static parent class method can not be overridden by subclasses
  6. Subclasses can define a static method with the same name as the parent class's static method
  7. Non-static methods of the parent class is not a static method subclasses cover
  8. Private parent method can not be overridden by subclasses
  9. Abstract parent class can be overridden by a subclass in two ways: ① ② again to achieve the abstract method is defined as an abstract class or method is implemented by Sun continues to abstract
  10. The method of non-abstract parent class may be covered as an abstract method

Guess you like

Origin www.cnblogs.com/leiblog/p/11588292.html