Easy-to-Forget knowledge in java, occasionally updated ......, Regular update...
If someone asks you: "Is it true that the subclass inherits all non-private attributes and methods of the parent class? "If you are right, I can only say too young too simple!
Modifier Problems
Why is this sentence incorrect? As long as you have figured out the application scope of the four access modifiers, you will know.
Public: access from anywhere
Private: Class accessors (get their own names), which can be accessed only in this class, but not in other classes.
Default: When the modifier is not added, it is the package access character, as long as it can be accessed in this package, other packages cannot be accessed (subclass in other packages cannot be accessed, this is exactly the same as protected)
Protected: The default value is + sub-class of the non-same package, that is, it can be accessed in this package and sub-class of the non-same package, but not in the non-sub-class of the non-same package.
You can write a case to verify it and help you better understand it. Then I will ask: "Is the implementation class 'inherited 'all non-private attributes and methods of the parent interface correct? "If you have been inspired by the above, you have to think carefully. first, this problem occurs because the attributes in the interface are modified by public static final by default, and the methods in the interface are modified by public abstract by default. Therefore, the interface does not have private attributes and methods, therefore, "the implementation class 'inherits all the attributes and methods of the 'parent interface" is correct.
How to verify it?
Static: verify whether the class name can be called directly in the Implementation class
Final: verify whether the attribute value can be modified in the implementation class.
Abstract: try to write a specific method in the interface.
Public: I don't need to mention that.
Other... will be updated later ......