I understand that upcasting/downcasting in objects do not change the object, but rather change how we deal with them. ( or change the type of their reference if I understand correctly).
However, if we have an Animal class that has a getName(); method, and a dog class which is a child class of Animal.
Animal Billy = new Animal("billy",1);
Dog b = (Dog)Billy;
b.getName();
I understand that it will compile, but give a run time error, my question is why, getName(); method is present in the Animal Class, and so it is inherited by the Dog class, so it's present in both, what prevents us from having it done?