hahahaha
I am such a fool!
I think I got the solution
I will tell what I am thinking but please tell me whether it is right or not !
here is the code
and the output
C:\Users\Prasad\Desktop>java SubClass
Super class constructor running now
counter = 1
something something
0
0
Super class constructor completes here
counter = 2
something something
4
0
According to me following things happen
1. Starting of main method
2. on the object creation line, the subclass constructor runs and the default values are assigned to the variables of the subclass and also the superclass constructor runs due to the implicit call to the superclass no-arg constructor
3.in the super class constructor we are calling the method print hence the method gets executed and the default values are printed
4. Now as the superclass constructor has completed, the control returns back to the subclass and explicit values are assigned to the variables in the subclass
5. Now again we are calling the method using the object hence the explicit values are printed
Is it right now?