The answer lies in runtime binding. For methods except private methods, JVM at runtime determines the actual type of a reference and invokes the appropriate method on the object. For instance variable, the binding is at compile time.
Hence the VM at compile time resolves reference a as a type A and thus displays 10.
posted 11 years ago
What are you doing? You are supposed to be reading this tiny ad!