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. In Java, Thanks 

Solution

public class Person

{

private String firstname;

private String middlename;

private String lastname;

public void setLastName(String lname)

{

lastname=lname;

}

public void setFirstName(String fname)

{

firstname=fname;

}

public void setMiddlename(String mname)

{

midldename=mname;

}

public String getMiddleName()

{

return middlename;

}

public String getLastName()

{

return lastname;

}

public String getFirstName()

{

return firstname;

}

Person(String f,String m,String l)

{

firstname=f;

lastname=l;

middlename=m;

}

Person(){}

public String toString()

{

return this.getFirstName()+this.getMiddleName()+this.getLastName();

}

public class Employee extends Person

{

private int employeeId;

Employee(){}

Employee(String f,String m,String l,nt id)

{

super(f,m,l);

employeeId=id;

}

public void setId(int i)

{

employeeId=i;

}

public int getId()

{

return employeeId;

}

public String toString()

{

return super.toString()+this.getId();

}

}

 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