First of all, please use the code tags, it's easier to read your code
Second, methods can override each other, but fields get accessed by the object you created.
In your code: A obj = new B(); the object obj is of type A, that means obj.i gets the field "i" from A. If you change your code to B obj = new B(); then obj.i calls the field "i" from B, because obj is now type B.