Parent Class Method name -> calculateTax Since Child Method name -> calculateTax
class will inherit this method I still want to call parent class calculateTax method
Child ch = new Child() ch.calculatetax() -> this should call parent class method , how can this be achieved
This is not possible, in your case since you are calling calculateTax method with the object of Child class. The method of child class will override the calculateTax of parent class.
But you can call the parent class method by using super keyword inside the child method body like:-
super.calculateTax ();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.