is inheritance replicated or shared? for example, if the dog inherits the animal class, and the property changes in the dog, will the attributes in the animal also change together? If the object is instantiated with dog and animal, is the attribute of both the dog and the animal, either public or separate, unrelated? In addition, to assign a value to a property that inherits from a subclass, through Super (), and eventually to the parent class constructor, is the parent object created?
1, common more appropriate, because some of the parent class private methods and private properties are not inherited, after inheritance, subclasses can share the parent class's public properties and public methods,
2, dog If you do not redefine the parent class already has the same name property, then modify the public property is to modify the parent class's public properties, that is, the parent class property will change together,
3, if both are instantiated, it is certainly two different objects, memory address can not be shared, even if the dog is instantiated multiple times is just a number of different objects, memory address is not the same,
4, super is actually a distinguishing mark, will not create new objects,, super () just call the parent class of the non-parametric construction method, because the subclass also has no parameter construction method, as long as the subclass to call in the parent class with the same name of the same parameter method or a property of the same name, you have to use super to distinguish,
is Java inheritance replicated or shared? Shared answers