Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[18 marks] (Inheritance) Design a class named Person and its two subclasses named Student and Employee. A person has a name, an address (a String

image text in transcribed
[18 marks] (Inheritance) Design a class named Person and its two subclasses named Student and Employee. A person has a name, an address (a String type), a phone number and an email address. A student has a year level number (1,2,3, or 4). An employee has a office and salary. Override the toString method in all the three classes to display the class name. Create appropriate constructor(s) for each class. But do not need to create any 3. accessor or mutator for any of the classes. Outside any of the classes above, define a method with the following header: public static void displayObject(Person object) This method calls the toString0 method of the Person object. Implement the classes and the method above. Write a test program that creates a Person object, a Student object, and an Employee object, and then call the displayObject metho three times to pass the three objects above to the method, respectively, to display the cl name of each object public class Tester

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions