AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Object Declaration Using Class That Extends Class

APCSA-AGD5VN

Consider the following classes.

public abstract class ConstructionWorker 
{
    private String name;
    private double hourlyWage;
    private int numHours;

    public ConstructionWorker(String nam, double wage, int hrs)
    {
        name = nam;
        hourlyWage = wage;
        numHours = hrs;
    }

    public double getHourlyWage()
    {
        return hourlyWage;
    }

    public int getNumHoursOnJob()
    {
        return numHours;
    }

    public String getWorkerName()
    {
        return name;
    }

    public void setHourlyWage(double newWage)
    {
        hourlyWage = newWage;
    }

    public abstract ArrayList<String> determineValidJobs();

    // other data and methods not shown
}
public class Roofer extends ConstructionWorker 
{
    public Roofer(String nam, double wage, int hrs)
    {
        super(nam, wage, hrs);
    }

    public ArrayList<String> determineValidJobs()
    {
        // implementation not shown
    }

    public void setHourlyWage(double wage)
    {
        if (wage &gt;= getHourlyWage())
            super.setHourlyWage(wage);
    }

    public void installRoof()
    {
        // Implementation not shown
    }

    // other data and methods not shown
}

Which of the following statements will compile successfully (without an error)?

A
ConstructionWorker sheila = new Roofer("Sheila", 10.00, 20);
sheila.installRoof();
B
Roofer greg = new Roofer("Greg", 12.00, 40);
System.out.println(greg.setHourlyWage(15.00));
C
ConstructionWorker helen = new ConstructionWorker("Helen", 16.00, 40);
System.out.println(helen.getWorkerName());
D
ConstructionWorker chad = new ConstructionWorker("Chad", 10.00, 20);
System.out.println(chad.getHourlyWage());
E
Roofer bubba = new Roofer("Bubba", 10.00, 20);
bubba.installRoof();