Create a class named Person The person class contains first

 Create a class named Person. The person class contains first name, middle name,  and last name.Then create a sub-class named Employee that inherits the  properties and attributes of the Person super class. The Employee  class returns the first name, middle name, last name and employee ID of two employees. 

Solution

Hi, Please find my implementation.

Please let me know in case of any issue.

public class Person {

  

   // protected instant members

   protected String firstName;

   protected String middleName;

   protected String lastName;

  

   // constructor

   public Person(){

       firstName = \"\";

       middleName = \"\";

       lastName = \"\";

   }

  

   public Person(String fname, String mname, String lname){

       firstName = fname;

       middleName = mname;

       lastName = lname;

   }

}

class Employee extends Person{

  

       // instance members

   private String employeeID;

  

   // constructor

   public Employee(String id) {

       employeeID = id;

   }

  

   public Employee(String fname, String mname, String lname, String id){

       super(fname, mname, lname);

       employeeID = id;

   }

   // setters and getters

  

   public String getEmployeeID() {

       return employeeID;

   }

  

   public String getFirstName() {

       return firstName;

   }

   public void setFirstName(String firstName) {

       this.firstName = firstName;

   }

   public String getMiddleName() {

       return middleName;

   }

   public void setMiddleName(String middleName) {

       this.middleName = middleName;

   }

   public String getLastName() {

       return lastName;

   }

   public void setLastName(String lastName) {

       this.lastName = lastName;

   }

  

  

   @Override

   public String toString() {

       return \"First Name: \"+firstName+\"\ \"+

               \"Middle Name: \"+middleName+\"\ \"+

               \"Last Name: \"+lastName+\"\ \"+

               \"Id: \"+employeeID;

   }

}

 Create a class named Person. The person class contains first name, middle name, and last name.Then create a sub-class named Employee that inherits the properti
 Create a class named Person. The person class contains first name, middle name, and last name.Then create a sub-class named Employee that inherits the properti
 Create a class named Person. The person class contains first name, middle name, and last name.Then create a sub-class named Employee that inherits the properti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site