1:final Keywords (master)
(1) is the final meaning, can be modified class, method, variable.
(2) Features:
A: It modifies the class and cannot be inherited
B: It modifies the method, cannot be rewritten
C: It modifies the variable, is a constant
(3) Interview Related:
A: Local Variables:
A: The base type value does not change
B: The reference type address value cannot be changed, but the content of the object can be changed
B: Timing of initialization
A: Initialize only once
B: Common given values
At the time of definition
In the construction method
2: Polymorphism (mastering)
(1) different states that the same object manifests at different times
(2) The precondition of polymorphism:
A: Having a succession or realization relationship
B: There is a way to rewrite
C: There are parent or parent interface references to child class objects
Classification of polymorphic:
A: Specific polymorphism
Class fu{}
Class Zi Ectends fu{}
Fu f = new Zi ();
B: Abstract polymorphic
Abstract class fu{}
Class Zi extends fu{}
Fu f = new Zi ();
C: Interface polymorphism
Interface fu{}
Class Zi implements fu{}
Fu f = new Zi ();
(3) Features of member access in polymorphic states
A: Member variables
Compile look left, run look right
B: Construction method
The construction of the child class will default to the construction of the parent class
C: Member Method
Compile look left, run look right
D: Static method
Compile look left, run look right
(4) Benefits of polymorphism
A: Improve the maintenance of code (inheritance embodies)
B: Improve code Extensibility (polymorphic representation)
(5) The drawbacks of polymorphism
The parent cannot use the unique features of the child
Phenomenon:
A child can be used as a parent, and the parent cannot use it as a child
(6) Transformation in polymorphism
A: Upward transformation
From child to Parent
B: Down transformation
From parent to Child
3: Abstract class (Master)
(1) To extract a number of common things into a class, this is the practice of inheritance
But there are many things that are common, in some cases, method declarations, but the method body
That is, the method declaration is the same, but each concrete object does not have the same content when the concrete implementation
Therefore, when we define these common methods, we can not give the concrete method body
And a method without a concrete method is an abstract method.
In a class, if there is an abstract method, the class must be defined as an abstract class
(2) Characteristics of abstract classes
A: Abstract classes and abstract methods must be cestoda with key Pro abstract
B: Abstract classes do not necessarily have abstract methods, but classes with abstract methods must be abstract classes
C: Abstract class cannot be instantiated
D: Subclass of Abstract class
A: is an abstract class
B: is a specific class. This class must override all abstract methods in the abstract class
(3) Characteristics of abstract class Members:
A: Member variables
There are variables, there are constants
B: Construction method
There are construction methods
C: Member Method
There is abstraction, there is non-abstract
4: Interface (Master)
(1) Features of the interface
A: interface with keyword interface decoration
B: Class implementation interface with Imp1ements modification
C1ass class Name implements interface name {}
C: interface cannot be instantiated
D: Implementation class of the interface
A: is an abstract class
B: is a specific class that must rewrite all the abstract methods in the socket
(2) member characteristics of the interface
A: Member variables
can only be constants
Default modifier: publis static FINA1
B: Construction method
No construction method
C: Member Method
It can only be abstract.
Default modifier: Public abstract
(3) Classes and classes, classes and interfaces, interfaces and interfaces
A: Classes and classes
Inheritance relationship, can only be single-inheritance, multi-layer inheritance
B: Classes and Interfaces
Implementation of the relationship, can be implemented alone, can also be implemented more
It is also possible to implement multiple sockets while inheriting a class
C: Interface and interface
Inheritance, can be single-inheritance, or multiple inheritance
(4) The difference between abstract class and interface (self-completion)
A: Member Differences
Abstract class
Interface
B: Relationship Difference
Classes and Classes
Classes and Interfaces:
Interfaces and interfaces:
C: Different design concepts
Abstract class: Is a, which is defined in the abstract class is a common function
Interface: 1ike A, the extension function is defined in the interface
First, Javase (ix) final, polymorphic, abstract class, interface