java object-oriented personal notes

Inheritance is java language only single inheritance, a subclass can have only one parent; but the interface addresses the limitations of single inheritance, a class can implement multiple interfaces.


Unique subclass of java to create the parent class object can not be accessed.


Interface methods are only abstract methods, even if the members without abstract method is an abstract method, as added by default abstract methods.

Only use modifiers public interface modifications, use other qualifier code error.

Features more than two interfaces, provide external specification.

Interface reduces the coupling of the program (modular development can be achieved, well defined rules, each person realize their modules, improve the development efficiency)


Class and class: inheritance, single inheritance, multiple layers inheritance.

Classes and interfaces: realization relationship, to achieve more than

Interface interface: inheritance


Polymorphism: parent (parent interface) of references to an object subclass (type reference type automatically upcast), polymorphism specific subclass method can not be used.

           Referenced polymorphic actual call parent class is (parent class subclasses rewritten, such as a set of List and ArrayList) subclass, polymorphism has been used in the factory mode.

Child-parent relationship class inheritance

Rewrite method

Pointing object referenced parent class subclass

Polymorphic members features:

Member variable: Compile look left, look left to run (compile-time checking the parent class member variables that have not, and if not, the compiler does not pass, the use of runtime variables of the parent class);

Member method: Compile look left, look right of the run (compile-time checking the parent class members have this method, if not, the compiler is not passed, calling the runtime method subclass of the class);

Static methods: Compile look left, look left to run


 

Guess you like

Origin blog.csdn.net/qq_20757489/article/details/92738822