Construction Method:
The constructor method has the same name as the class name, there is no return type, and the argument list (type, number) is different
Method overloading: Both member methods and construction methods can be overloaded
The method name is the same but the argument list (type, number) is different, which becomes the overloaded method.
Inheritance: direct support for single inheritance, a class can have only one parent class
Inheritance to be decorated with the extends keyword
public class Dog extends pet{
Method body
}
subclass calls the member variables and methods common to the parent class using the keyword supe R like super. Method Name Super (member variable, member variable ....) )
Method overrides:
Requirements for method rewriting:
1. The overriding method and the overridden method name must be the same
2. The override method and the parameter list of the overridden method must be the same
3. The override method must be the same as the return value type of the overridden method
4. The override method cannot be less than the access permission of the overridden method
Subclasses that inherit the parent class do not satisfy the requirement, overriding the method with the same name as the parent class in the child Class (overwrite)
The difference between overloading and overriding:
Overloading: To the same method in the same class, requires the same method name, the number of lists is different, and the return value and modifier Independent
Override: Subclass and Parent class with the same name method, method name, parameter list and return value type, access modifier cannot be greater than parent class
Enforcing method overrides: Abstract classes and abstract methods:
Abstract class with keyword abstract keyword decoration
Classes that are decorated with an abstract cannot be instantiated, and the parent class method, which is decorated with the abstract, must be overridden by the subclass
Final modifier:
The final decorated class cannot be inherited
The final modified method cannot be overridden
Final modified variables (including members and parts) become constants and can only be assigned once
Deep understanding of Final click
In Java (constructor, method overload, final modifier usage, and inheritance and abstraction)