This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I read in Kathy sierra that variables are not inherited so came up with the example to do this and earlier had the i as protected to showcase i can be accessed only via constructor and nowhere else and then I thought what if we had a constructor that would call the i which would it print .To cut a long story short experiment with what I have iterated to this point .
As Deepak said, the JVM will use the "closest" variable. If you shadow the member's variable with a local variable, you'll see just how the JVM resolves which variable it uses. Also comment the lines 2, 5 and/or 20 in the below code to get a better understanding of the difference between no prefix (just "i"), this.i and super.i.
Here at line # 9, gc1 is of type Parent and constructor grandchild() is called. Hence in constructor it will print i=9, but later gc.i will be 1 as its type is Parent. if its type is changed from Parent to grandchild, it wil print gc.i=9