According to the SCJP6 (Page 507) i found that instance variables are assigned default values before the superclass constructors complete, i tried an example in Debugg mode but i saw that the super contractor runs before instance variables get their default values, could any one explain that to me ?
Example i used in case someone want to try it:
package courseExercise;
class test {
test() {
System.out.println("Super Constructor run");
}
}
public class Init extends test {
private Integer i = 6;
private int j = 8;
Init(int x) {
super();
System.out.println("1-arg const");
}
Init() {
System.out.println("no-arg const");
}
static {
System.out.println("1st static init");
}
public static int d = 10;
{
System.out.println("1st instance init");
}
{
System.out.println("2nd instance init");
}
static {
System.out.println("2nd static init");
}
public static void main(String[] args) {
new Init();
new Init(7);
}
}
See Question&Answers more detail:os