class Super {
int a =f();
int f() {
return 1;
}
}
class Sub extends Super{
int b = 2;
int f() {
System.out.println("Print");
return b;
}
}
public class Test7 {
public static void main(
String[] args) {
Super sup = new Sub();
System.out.println(sup.a);
System.out.println(sup.f());
}
}
The output is print 0 print 2
I hope the first print is happening during the intialization of the variable : a but it is not assigned the value 2.please explain instance intializer.