java-Overview of object characteristics
the connection between an object and an object
Dependent
Associate
aggregations can be independent
Combination not independent
inheriting the relationship of the subclass parent class
Two packaging Java files
Packaging Java Files
Jar CVFM Test.jar ***.MF ***.class class file
Unpacking Run
Java-jar Test.java
Three inheritance
subclasses (derived classes) inherit the parent class (the base class), inheriting from the inherited relationship, and facing the object is the interaction between different objects.
Keyword extends
public class S extends f{}
Private methods and variables cannot be inherited
four overriding and overloading of methods
cover
subclasses override the parent class with the same name method
1 method names are the same
2 parameters Consistent
3 Subclass method modifier greater than or equal to parent class modifier
4 have an inheritance link
5 appears in different classes, that is, subclasses and parent classes
Overloaded
Overloads of the method appear in a class
Five polymorphic
Parent Class object = new Subclass
The object points to the child class
If the parent class and child class have overridden the method, the object still calls the subclass's override method
Object can be used as a parameter to a method
six this and super
1 This
THIS.A ();
Invoke with Point
2 Super
The precondition is that the subclass inherits the parent class
using super in subclasses
The parent class first constructs
Subclasses are constructed
Super () Represents the constructor method for calling the parent class
SUPER.A () represents the method that invokes the parent class
Seven abstract classes and interfaces
Abstract class
Keyword abstract
GCA, Animal class
1 can have member variables
2 can have a construction method
3 can have modifiers
4 can have an abstract method, no method body method (no curly braces), containing the ABSTACT keyword public abstract void eat ();
5 abstract methods of abstract classes must be overridden by the quilt class to instantiate
Interface
The interface is also a special abstract class
1 contains member variables that are more advanced than abstract classes
2 All are abstract methods, abstract, can have non-abstract class
3 The member variables of the struct must be initialized, and the contents of the parentheses are added by default
(public static final) int age = 10;
4 inheriting public class Stu implement person{} Subclasses must implement all abstract functions of the interface
java-Overview of Object characteristics