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 12 years ago
I child proofed my house but they still get in. Distract them with this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java