I have a parent class, A, and a child class, B, and B overrides a method, f, from A.
public class A
{
public String f()
{
return \"A\";
}
When you cast the instance you are simply implying that it could be an instance from the super class, BUT the internal implementation of that instance will not change, that's why you get that result!
Metaphorically speaking, if you applied an american's person mask on an UK person (cast), that person would still be english (inheritance), but if you asked that person to speak (calling a method) you would still hear the british accent, not the american one (internal implementation is what matters in the end) :-)