Limited access

Upgrade to access all content for this subject

When designing the following classes, assume that a Desk is a Furniture. To construct a Furniture object, you must provide the cost (in dollars/cents) and the weight (in nearest pounds). To construct a Desk object, you must also provide the cost and weight, as well as the description of the desk and its height, width, and depth.

Consider the following class.

public class Furniture 
{
    private double cost;
    private int weight;

    // This is the only constructor method
    public Furniture(double c, int w) 
    {
        cost = c;
        weight = w;
    }

    // other data and methods not shown
}

What would be a valid definition of the constructor method in the Desk class?

A
public class Desk extends Furniture 
{
    public Desk(int weight, double cost, String desc, double h, double w, double d) 
    {
        super(weight, cost);
        // other statements not shown
    }

    // other data and methods not shown
}
B
public class Desk extends Furniture 
{
    public Desk(double cost, double weight, String desc, double h, double w, double d) 
    {
        Furniture(cost, weight);
        // other statements not shown
    }

    // other data and methods not shown
}
C
public class Desk extends Furniture 
{
    public Desk(double cost, double weight, String desc, double h, double w, double d) 
    {
        super(cost, weight);
        // other statements not shown
    }

    // other data and methods not shown
}
D
public class Desk extends Furniture 
{
    public Desk(double cost, int weight, String desc, double h, double w, double d) 
    {
        super(cost, weight);
        // other statements not shown
    }

    // other data and methods not shown
}
E
public class Desk extends Furniture 
{
    public Desk(double cost, int weight, String desc, double h, double w, double d) 
    {
        super(cost, weight, desc, h, w, d);
        // other statements not shown
    }

    // other data and methods not shown
}
Select an assignment template