Using super.method()

Part of: Inheritance

Reusing the Parent's Version When you override a method, the superclass version is hidden for that subclass. But often you want to extend the parent's behavior, not throw it away. The expression super.method() calls the superclass's version of a method from inside the subclass. The Pattern Calling new Dog().describe() returns "I am an animal and a dog". The subclass builds on the inherited logic by first calling super.describe(), then adding to it. Why super.method() Matters - It avoids duplicating the parent's code. - It lets each level of the hierarchy add its own contribution. - It keeps the parent in charge of the part it owns. Without super, writing describe() inside Dog's own describe() would call the Dog version again, causing infinite recursion . The super. prefix is what breaks out to the parent. super vs. this - this.method() calls the current object's version (which may be overridden). - super.method() calls the superclass's version, skipping the override. A Common Use A classic example is toString(). A subclass often does: This reuses the parent's formatting and appends new fields. In the challenge you will build a Manager whose info() calls super.info() from Employee a

Challenge: Manager Info