You are half right.
XClass is loaded, value of s is set as 1.
s is an instance field. So it will be set when instance of XClass or it's subclass is created.
he instance initializer in XClass does not run, as it is not instantiated.
Again wrong. The initialization expression i.e. when s is set to 1 will be executed when an instance of XClass or it's subclass is created. Then the initializer block will execute and it will set the value of s to 2;
Then instance initializer of YClass euns, sets the value of s=3.
Since s is not declared in YClass, it is the same as that of super class.
Right this time. There is no s in YClass so s and super.s refer to the same field.
So the flow of execution goes like this
XInterface xi=new YClass();
is executed. As a consequence first int s=1; is executed so s is set to 1. Then
{
s=2; //in class XClass
}
is executed so s is set to 2. Then
{
s=3; //in class YClass
}
is executed so s is set to 3. Then the value 3 is displayed 2 times...