Java Basics (Second, overloading, inheritance, polymorphism, overwrite)

The following is the main reference notes organize video tutorial: 2019 version of java-based idea engineer classes + travel project combat , with the book Java core technology perspective, more detailed video, this article is for reference only.


1, overloading:

4693288-27a1bab205b00925.png
image.png
4693288-189520ac8870e5aa.png
image.png

2, inheritance

Features members inherited method (method of the same name)

4693288-84cc7bb1e136f540.png
image.png

3, polymorphism:

4693288-72da76ae3139ded0.png
image.png

Polymorphism is defined:

-> Multi-state members:

Member method of access rules

4693288-e93f4ce3531a5df7.png
image.png
4693288-14a5f932cf3b3018.png
image.png

-> member variable of polymorphism:

4693288-eb3e273296ebb354.png
image.png

Polymorphic benefits:

4693288-12168c078fb22fc5.png
image.png

Transformation and transition up and down the object:

4693288-f6c87746d276ef23.png
image.png
4693288-cf37b131647cf122.png
image.png

4, overwrite:

-> Case rewritten and overloading:


4693288-c8e6dc7510f0be93.png
image.png

Overwrite method:

4693288-188807a85b10776b.png
image.png

scenes to be used:

4693288-b6d373b8cd64f664.png
image.png

Note : the implementation process, try not to modify the old class, to overwrite add new content

Example:

father:

4693288-63c1c69fe903efc0.png
image.png

Subclass:

4693288-cf111e4d7cdfa01d.png
image.png

Main method:

4693288-0b7e19d0672a772a.png
image.png

Sons class constructor:

Constructor : constructor has no return value, the method name and the class name, its role is for NEW a class, will always first call the constructor of this class, the internal structure of the method can be used for initialization of some variables or in the creation of this Some methods and operations must be called when the class, he is not deliberately method to call, it will automatically create a class as to call

4693288-a04e0339d8871b16.png
image.png

supper Keywords:

4693288-7a5c77e0a34dec7b.png
image.png

Three uses this keyword:

4693288-2ba14da092cb81bd.png
image.png

Memory schematic:

4693288-41aa4e99d4638f28.png
image.png

5. Inheritance:

4693288-45b144b52c65ddca.png
image.png

Abstract methods:

4693288-ad3a8996c6d10ad0.png
image.png

Abstract class abstract methods:

The parent class is a subclass of the properties and methods have in common extraction, these properties and methods, some have clearly realized, and some can not be determined, then we can be defined as abstract, leaving its subclasses to achieve.

For example, the definition of "animal" parent class, where "Animal name" and "age of the animal" Properties have been identified, but the "animal called" approach is not clear, then you can be "called animal" is defined as an abstract method.

4693288-f08db327c872460e.png
image.png

Multiple inheritance:

4693288-d9fc51da2054deb8.png
image.png

Attachment: notes, links: https://pan.baidu.com/s/1wg8yO0zZFF2Z8g83gLMoYw
extraction code: 70je

Reproduced in: https: //www.jianshu.com/p/04e98e17df46

Guess you like

Origin blog.csdn.net/weixin_33670786/article/details/91105087