The question is quite simple, as can seem to much.
In General:
abstract class A {
int a = 8;
public A() {
show();
}
abstract void show();
}
class B extends A {
int a = 90;
void show() {
System.out.println("" + a);
}
}
And in the main method create an object of class B:
public static void main(String args[]) {
new B(); // output - 0
}
It is understandable, the superclass constructor will cause a polymorphic version of the show (especially in the base class it is abstract). The context variable is
a change (one that is in the class B was not yet initialized to a value of 90, because it happens in the constructor?). But first, when you create an object B needs to be initialized its parent, all the fields that are there. When, then, the JVM has time to initialize the field to
a zero when the command first calls the superclass constructor?
And that's all, if you slightly change the code in class B:
class B extends A {
int x = 90; // changed the variable name!
void show() {
System.out.println("" + a); // 8
}
The printed value of the variable
a from the context object
A - 8. Then I can still somehow understand that you initialize a variable before the call f-tsii show. Like that:
public A() {
super(); // constructor Call Object and
a = 8;
show();
}
But when the time to initialize the field
a in the context of object B, if at all, first the JVM is running on its base class? In General there are there subtleties?