Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
please solve this by JAVA In this lab, the following topic will be covered: 1. Inheritance Task Design a class Person that has two subclasses
please solve this by JAVA
In this lab, the following topic will be covered: 1. Inheritance Task Design a class Person that has two subclasses Student and Employee. A person has a name and a phone number. A student has an id and GPA. An employee has an id and monthly salary. Note: All instance variables must be declared as private. Include in each class a constructor that has all the data fields. In each class override the toString() method to return the data fields. For the Person class include getter and setter for phone number and a getter for name. For the Student class include getter and setter for GPA. For the Employee class include getter and setter for monthly salary. Note: For the setters assume that the parameters are valid. Write a test program that creates three objects: a Person object referenced by person, a Student object referenced by student, and an Employee object referenced by employee. Display the details of each object using its toString() method. Here is a sample run of the program: Name: Salem, Phone number: 0501331845 Name: Reem, Phone number: 0564448202, ID: 200000, GPA: 3.6 Name: Saad, Phone number: 0563428255, ID: 200003, Monthly salary: 16000 SAR
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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