Java inheritance – instance variable override

Why is the instance variable of a superclass not overridden in inheritance?

Solution

Because inheritance is to modify behavior Behaviors are exposed through methods, which is why they can be covered

A field is not a behavior, but a state You do not need to modify it, nor do you need to use the private methods of the superclass They are designed to allow superclasses to do their work

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>