Let's say I have this piece of code:
class Animal {
int legs = 4;
int head = 1;
}
public class Dog extends Animal {
public static void main (String []args) {
Dog dog = new Dog();
}
}
I am aware of the super() implicitly placed in the first line of the no-args constructor, so I know that the Animal constructor will be executed and so the Animal's instance variable will be set.
To this purpose I would like to understand if, once those variables have been initialized by the super constructor (Animal), those instance variable will be kept there in the Animal object or copied to the subclass (Dog).
In the first case an object Animal will be instantiated implicitly by super(); and whenever the instance Dog will need to access one of those variable it will be done accessing to the variables kept in the instance Animal (created on background). Or second case, if the object Animal will be temporary created, all the instance variable (in Animal) copied to the Dog instance and then deleting the Animal's instance temporary created.
I personally think that for example a Dog object would be directly linked to an Animal object which is directly connected to an object.
Is it in this way?