A: a package
Features: hide implementation details, provide external access ways.
The keyword private properties and methods of privatization.
Implementation process:
In SetColor () method can limit the input of the caller. Increased security class.
Two, this keyword
You can distinguish between members and local variables
Variable get with this / member variable is set
Note: Who calls this points to that object
Three: Inheritance (extends)
Note: inheritance only single inheritance (subclass can only inherit from a parent class), but the parent class can be inherited by subclasses
Format: class subclass extends parent class {}
Subclasses can access methods and properties of the parent class.
Advantages: 1, the emergence of inherited improve reusability of code, improve software development efficiency.
2, the emergence of inheritance between class and class had a relationship, provide a prerequisite of polymorphism.
If the child class needs to call the parent class with super keyword super. Property / Method
Subclass override the parent class: the premise: There inheritance, return values, method name, parameter list consistent
Note: When the parent class subclass overrides, visit modified sub-grade class method access modifier than the parent class
Difference: and overloaded methods override method;
Overload: Premise: In the same class, the same method name, a list of different parameters