Java method overriding and variable shadowing

Method calls are virtual in Java, which means that the method from an object’s actual type is called, regardless of what type the reference was which you used to access the object. Direct field access on the other hand is not virtual, so which r you access will depend on the type of the reference through which you reached it.

Leave a Comment