+ 1
If I need to declare the same method every time I extend the class then what is the use if we declare method again?
May I use the same method with some changes in inherited class?
2 Respuestas
+ 2
yes, just make a new method with the same name and whatever changes in the child class. When an instance of the child class calls the method, it will be the overridden version. Thats at least how it is in Python
+ 1
Slick is correct theres no other way to tell the 2 methods apart unless you mention the overridden method in sub class,
Once you have created an instance of the sub class but used parent class as the refrence type the correct method will be called on your sub class instance during runtime your object will always act like it should because it is of couse a sub class object. This works because of polymorphism as the parent Class should know the basics of what its sub classes can do.