Question: With java, define a class named Person that contains two instance variables of type String that stores the first name and last name of a

With java, define a class named Person that contains two instance variables of type String that stores the first name and last name of a person and appropriate accessor and mutator methods. Also create a method named displayDetails that outputs the details of a person.

Define a class named Student that is derived from Person. Student should have instance variables of student ID, course, and teacher name. The class Student should have appropriate constructor(s), which should call the constructor of Person, which should receive first name and last name from the class Student. The constructor of Student should also take values to the corresponding instance variables. This class should redefine the displayDetails method to print person details as well as details of a student.

Define a class named Teacher that is derived from Person. This class should include appropriate constructor(s), and and contain instance variables for the subject name and salary. Finally, redefine the displayDetails method to include all teacher information in the printout.

Create a main method that creates at least two student objects and two teacher objects with different values and calls displayDetails for each.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!