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 3 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_1?
public class Volunteer{
private String host;
private String project;
public Volunteer(String firstName,String lastName,String jobTitle,String host, String project){
super(firstName,lastName,jobTitle);
this.host = host;
this.project = project;
}
public String getHost(){
return "Host "+ this.host;
}
public void setHost(String newhost){
this.host = newhost;
}
public String getProject(){
return "Project "+ this.project;
}
public void setProject(String project){
this.project = project;
}
}
Volunteer volunteer_1= new Volunteer("John","Doe","Volunteer","Jane Doe","Project_X");
public class Volunteer extends Person {
private String host;
private String project;
public Volunteer(String 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 setHost(String newhost){
this.host = newhost;
}
public String getProject(){
return "Project "+ this.project;
}
public void setProject(String project){
this.project = project;
}
}
Volunteer volunteer_1= new Volunteer("John","Doe","Volunteer","Jane Doe","Project_X");
public class Volunteer extends Person {
private String host;
private String project;
public Volunteer(String firstName,String lastName,String jobTitle,String host, String project){
super(firstName,lastName,jobTitle);
this.host = host;
this.project = project;
}
public String getHost(){
return "Host "+ this.host;
}
public void setHost(String newhost){
this.host = newhost;
}
public String getProject(){
return "Project "+ this.project;
}
public void setProject(String project){
this.project = project;
}
}
Volunteer volunteer_1= new Volunteer("John","Doe","Volunteer","Jane Doe","Project_X");
public class Volunteer extends Person{
private String host;
private String project;
public Volunteer(String firstName,String lastName,String jobTitle,String host, String project){
super(firstName,lastName,jobTitle,host,project);
this.host = host;
this.project = project;
}
public String getHost(){
return "Host "+ this.host;
}
public void setHost(String newhost){
this.host = newhost;
}
public String getProject(){
return "Project "+ this.project;
}
public void setProject(String project){
this.project = project;
}
}
Volunteer volunteer_1= new Volunteer("John","

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!