5.1 superclass class (parent class, the base class) subclass (derived class)
Use the keyword extends to inherit
For subclasses would like access to the private domain of the parent class, you must be using the public interface, public methods in the parent class is such an interface
In order to prevent the subclass defined with the same parent class member functions, you can use a particular keyword super to solve:
super. super parent class member functions with reference to the concept of different, it's just a special keyword instructs the compiler to call the superclass method does not bring the super assigned to another object variable
In the sub-category method can increase the field to increase or superclass method covering, but any fields and methods must not remove the inherited
An object variable can indicate a variety of actual type of phenomenon is called polymorphism, which can automatically select the method to call the phenomenon known as dynamic binding at runtime.
5.1.1 inheritance hierarchy
Inheritance is not limited to the next level. Derived from a common superclass set of all classes is called inheritance hierarchy. In an inheritance hierarchy, from a certain class to the path of their ancestors is called class inheritance chain
5.1.2 Polymorphism
Should be designed to determine whether the rules of inheritance that is "is-a" rule, which indicates that the object of each object is a subclass of the superclass.
5.1.3 Dynamic Binding
When the program runs and the virtual machine will call the actual type of the object of the most appropriate method of that class and x referenced when using dynamic binding to call a method, and looking up layer by layer
5.1.4 Block Inheritance: final classes and methods
5.1.6 abstract class
Abstract parent class needs to contain abstract methods. Implement a plurality of common attributes in subclasses of the parent class
Particular abstract methods in the subclass. Extend the abstract class has two options:
In a subclass or a portion of abstract methods defined in an abstract method is not scheduled, so that it must be also labeled subclass of abstract class;
Another approach is to define all the abstract methods, which is not a subclass of abstract.
An abstract class can not be instantiated, if a class is declared as abstract, you can not create objects of this class; but you can create a specific subclass of objects;
Note: You can define an object variable is an abstract class, but it can only refer to objects non-abstract subclass.
5.1.7 Protected Access:
Superclass method allows some quilts access, or allow access for subclasses of a superclass field, which requires these methods or fields declared as protected.