014-006-008
super Call in Method Chain
Medium
Problem Description
super Call in method Chain
In this problem, you will create a program that uses the super keyword across a 3-level class hierarchy (Grandparent→Parent→Child) to chain parent method calls and displays each level's message to standard output in sequence.
Learning Objective: Understand method chaining with super in inheritance hierarchy
Overview
Create a program with 3-level class inheritance where each level calls methods via super, stacking processing.
Specifications
- Grandparent class has greet() method (outputs "Hello from Grandparent")
- Parent class extends Grandparent and overrides greet() (calls super.greet() then outputs "Hello from Parent")
- Child class extends Parent and overrides greet() (calls super.greet() then outputs "Hello from Child")
- Call greet() on child instance in Main
Output Format
Hello from Grandparent
Hello from Parent
Hello from Child
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up