public class SmallClass implements InterfaceA
{

   ordinary class definition body

}

A good answer might be:

Yes. You might wonder that it does not extend a base class, but it does. If no other class is extended, Object is the base class. SmallClass extends Object and implements InterfaceA.

Example Problem

Let us create a database program for a store. The store sells:

  • Goods, each of which has the attributes:
    • description
    • price
  • The goods are either:
    • Food -- with an attribute "calories"
    • Toy -- with an attribute "minimumAge", or
    • Book -- with an attribute "author."
Of these goods, toys and books are taxable, but food is not. There are many other things that are taxable, such as services or entertainment so we want to have the concept "taxable" as a separate concept, not part of the concept of Goods.

Here is what the concept Taxable will look like:

  • A Taxable item,
    • has a taxRate of 6 percent,
    • has a calculateTax() method.
When implemented in Java, these concepts will appear as classes and an interface.

QUESTION 5:

(Design question: ) Decide on an implementation for each concept:

ConceptParent Class,
Child Class,
or Interface?
Goods  
Food  
Toy  
Book  
Taxable 
Click Here after you have answered the question