Starting the Program

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

  • What method(s) will Food have?
    • display()
  • What method(s) will Toy have?
    • display() and calculateTax()

Starting the Program

Here is a class definition for Goods:

class Goods
{
  String description;
  double price;

  Goods( String des, double pr )
  {
    description = des;
    price       = pr;
  }

  void display()
  {
    System.out.println( "item: " + description +  " price: " + price );
  }
}

Here is a skeleton of the class Food, a child of Goods. It adds the variable calories.

class Food 
{
  double calories;

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

  void display()
  {
    super. ;
    System.out.println( "calories: " + calories );
  }
}

QUESTION 8:

Fill in the blanks. Click here for a