Question
Modify the Person super class exercise to include an additional class called Adult. The Adult class will also extend the Person class. The Adult subclass
Modify the Person super class exercise to include an additional class called Adult. The Adult class will also extend the Person class.
The Adult subclass will require a variable workLocation of type String in addition to the age variable. Include the proper get and set methods.
Modify the Test class to include an array of type Person. Instantiate one adult and one child object, placing them in the array. Loop through the array and call the getAge() methods of each object. After looping, call the getSchool() method of the child object and the getWorkLocation() of the Adult. Finally call the speak() methods of each object, passing in a phrase for each.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started