go to previous page   go to home page   go to next page highlighting

Answer:

The blanks are filled in, below.


Child Class

The child class Food extends the parent class. It uses super to use the parent's constructor and the parent's toString() method.

public class Food extends Goods
{
  protected double calories;

  Food( String des, double pr, double cal)
  {
    super( des, pr );
    calories = cal ;
  }

  public String toString()
  {
    return super.toString() + calories + " calories";
  }
}

QUESTION 9:

(Review :) Would it be correct to reverse the order of the statements in the constructor for Food?


go to previous page   go to home page   go to next page