Well the answer is in the behaviour of Classloader/Intilization. JLS: A class/interface is initialized when either its static variable/method is called for the first time, in the above case when the C is used in the main method the initilizer tries to initilize the C it reaches line int C= which uses interfaceA so it will try to initilize A when it reaches A= it uses B= so it initilize B it reaches B= which uses C again as C is in mid of initilization if a variable is used in mid of initilization the default value is returned its similar to using a variable of a subclass in super class constructor. Hence the the value returned for int B= 0 + 1 and rest is calcuated, but when the control comes to the main method the interfaceC is fully intilized it can now get value of C. Hope this answered your question.
Post by:autobot
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
a bit of art, as a gift, the permaculture playing cards