I just noticed that overriding methods does behave different than overriding fields.
Considering the following snippet:
public class Bar {
int v =1;
When you are calling foo.printAll(); It is calling the function of the base class which is printing the value 1. Then you are calling printV.This time since the inherited class has a function of the same name, it is overridden and printV of Foo is called.
The value of v depends on from which class you are printing the value.
I just noticed that overriding methods does behave different than overriding fields.
There's no such thing as "overriding fields". You can shadow fields, but you can't override them. Fields aren't polymorphic. See section 6.4.1 of the Java Language Specification for more details.
Note that in general, fields should almost always be private anyway, which means you wouldn't be aware of this in the first place.