014-006-004
Calling Parent Method with super.methodName
Hard
Problem Description
Calling Parent method with super.methodName
In this problem, you will create a program that defines Employee and Manager classes, calls super.getInfo() within Manager's getInfo() to append department information to the parent's name info, and displays the result to standard output.
Learning Objective: Understand how to call parent class method from within an overridden method
Overview
In a Manager class that overrides Employee's getInfo() method, use super.getInfo() to append additional information to parent's info.
Input Format
Employee name
Manager name
Manager department
Specifications
- Employee class: name field, getInfo() method (returns name)
- Manager class: department field, overrides getInfo()
- Manager's getInfo() gets parent info via super.getInfo() and adds department info
- Read 3 lines from standard input using Scanner to create Employee and Manager
Output Format
Name: {employee name}
Name: {manager name}, Department: {department}
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