Picture of the Classes

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:

ConceptParent Class, Child Class, or Interface?
Goods Parent Class
Food Child Class
Toy Child Class
Book Child Class
Taxable Interface

Picture of the Classes

various goods

 

Here is a picture that shows the classes and the interface. The children classes extend their parent. This is shown with a solid arrow pointing at the parent.

The solid arrows show inheritance. The three children inherit the display() method from their parent, Goods.

Two of the classes implement the interface. This is shown with a dotted arrow pointing at the interface.

The dotted arrows show what a class must implement. The Toy and Book classes must implement the calculateTax() method.

QUESTION 7:

According to the picture,

  • What method(s) will Food have?
  • What method(s) will Toy have?