I am trying to understand the
Java dispatch system. Here is the code I am trying to think through,
When I run new B(0), it is understandable why it prints 10 and 10 - because in both cases I am printing referring to the instance variable in class A.
But in new B(), the second line in
test() function does not seem to refer to the instance method of A, and instead, it seems to refer to the instance method of B despite the cast to A.
Why the cast is working with instance variable but not for instance methods?