It compiles because main can acces prvate variable i because main is in the class which holds i. So it can access everything from that class.
It gives 0 because the initialization of member variable i is done BEFORE the initialization of the member variable j. So first giveMeJ return default value of j, which is 0 for int type.