Java Basics - Inheritance Java foundation - initialize an object, its parent will instantiate it

Subclass inherits the parent class's private fields it?

Oracle's Java Documentation of the definition of Inheritance:

 Very straightforward, the definition of which will tell you this is not called inheritance. Inheritance means that you can be direct calls and modification . Public by the parent set get indirect method to modify, not inherited.

 

Why do so many answers to that network still say "inheritance" of the parent?

Because they misunderstood "inherited" meaning misinterpreted as similar to the "sub-class comprises the parent class," "When a subclass is instantiated, the parent class if there is to allocate memory" and the like.

First, construct a class, can be traced back to Object to construct all of its parent classes, see: the Java foundation - initialize an object, its parent will instantiate it . In other words, whether it is private is not private, parent class has been well constructed, the memory already exists, not because it is a private not allocate memory.

 

Guess you like

Origin www.cnblogs.com/frankcui/p/11990879.html