8.7 Succession Chapter Summary

  1. Inheritance can extend an existing class function. extends keyword is achieved by the members of the parent class can be inherited by subclasses.
  2. java before constructing method of performing sub-class will first call the parent class no-argument constructor, its purpose is to members inherited from the parent class to do the operation is initiated, when the parent class instance constructors finished calling the subclass constructor.
  3. When there are multiple parent class constructor, if you call a particular constructor, you can subclass constructor method, the super () class keyword completion.
  4. this construction method is to call another within the same class, super () call is the parent class constructor from a subclass constructor.
  5. Use this call to property or method when it will start in this class look, if this class is not found, then look from the parent class; using super (), then looks for the required property or method directly from the parent class .
  6. and this super () which similarities: (1) when the constructor has overloaded, both according to the type and number of the parameters given, the correct execution of the corresponding constructor; (2) both the first line must be written in the constructor, it is precisely for this reason, this and super () can not exist simultaneously within a constructor.
  7. "Overload" (Overloading is the) is a defined in the same class with the same name, but different number of parameters or parameter type method, can therefore based on the number or type of java call parameters corresponding method.
  8. "Override" (Overriding) is defined in the subclass name, number and type of parameters are the same as the parent class method, a method to override the parent class.
  9. If a parent class does not want to quilt class override, can be added before the final keyword in the parent class method, it will not be overwritten.
  10. Another function is the final add him in front of the data member variables, so the variable becomes a constant, it can not make changes in the program code. Public static final use may declare a global variable.
  11. Object Polymorphism automatically divided into the transition object casts a downward direction, in order to prevent downward transition ClassCastException conversion when abnormality may be determined by using the instance type instanceof keyword before the transition.
  12. All classes inherit from the Object class, all references to data types can be upcast to Object class, the method may be implemented using Object receive parameters or return consolidated data types.
Published 162 original articles · won praise 9 · views 3112

Guess you like

Origin blog.csdn.net/ll_j_21/article/details/104440483