1: What is the difference between a method override and a method overload? Can the method overload change the return value type?
Method overrides:
In a subclass, a behavior that is identical to the method declared in the parent class appears. (includes method name, parameter list, and return value type)
Method overloads:
In the same class, the method names that appear are the same, and the argument lists are different, regardless of the return value type.
The method overload can change the return value type because it is independent of the return value type.
Override: Method Overrides
Overload: Method Overloading
What does the 2:this keyword and super keyword stand for? and their respective use scenarios and roles.
This: Represents an object reference for the current class.
Super: Represents the identity of the parent class storage space. (It can be understood as a reference to the parent class, through which the members of the parent class can be accessed.) )
Application Scenarios:
Member variables:
this. Member variable
Super. Member variables
Construction Method:
This (...)
Super (...)
Member Methods:
This. Member method
Super. Member Methods
Two polygon questions for method rewriting in Java