Question: For the base public class Person example provided in the Unit 3 Revisiting the Employee Class Program tutorial, what if you need to add a
For the base public class Person example provided in the Unit Revisiting the Employee Class Program tutorial, what if you need to add a subclass for Volunteers who have a host employee and are assigned to a project.
What code segment could implement this subpublic class and create an instance of it called volunteer
public class Volunteer
private String host;
private String project;
public VolunteerString firstName,String lastName,String jobTitle,String host, String project
superfirstNamelastName,jobTitle;
this.host host;
this.project project;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getProject
return "Project this.project;
public void setProjectString project
this.project project;
Volunteer volunteer new VolunteerJohn"Doe","Volunteer","Jane Doe","ProjectX;
public class Volunteer extends Person
private String host;
private String project;
public VolunteerString firstName,String lastName,String jobTitle,String host, String project
super;
this.host host;
this.project project;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getProject
return "Project this.project;
public void setProjectString project
this.project project;
Volunteer volunteer new VolunteerJohn"Doe","Volunteer","Jane Doe","ProjectX;
public class Volunteer extends Person
private String host;
private String project;
public VolunteerString firstName,String lastName,String jobTitle,String host, String project
superfirstNamelastName,jobTitle;
this.host host;
this.project project;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getProject
return "Project this.project;
public void setProjectString project
this.project project;
Volunteer volunteer new VolunteerJohn"Doe","Volunteer","Jane Doe","ProjectX;
public class Volunteer extends Person
private String host;
private String project;
public VolunteerString firstName,String lastName,String jobTitle,String host, String project
superfirstNamelastName,jobTitle,host,project;
this.host host;
this.project project;
public String getHost
return "Host this.host;
public void setHostString newhost
this.host newhost;
public String getProject
return "Project this.project;
public void setProjectString project
this.project project;
Volunteer volunteer new VolunteerJohn
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
