I have my next question. I have extended a class, Parrent and overridden one of its method in the Child class. I tried to cast the type to the supercla
Parrent
Child
Method resolution occurs at runtime, not compile time. The object's class (its behaviour) declares an implementation of the method, so that is used.
Being able to refer to objects by their superclass is the essence of OOP. See Liskov substitution principle