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
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