The blanks are filled in, below.
The child class Food
extends the parent class.
It uses super
to use the parent's constructor and
the parent's display method.
class Food extends Goods { double calories; Food( String des, double pr, double cal) { super( des, pr ); calories = cal ; } void display() { super.display( ); System.out.println( "calories: " + calories ); } }
Here is Taxable
:
Taxable
item,
taxRate
of 6 percent,
which should be a double
constant. calculateTax()
method.
which should return a double
value.
The Taxable
interface looks like this:
interface Taxable { final double _____ = ______ ; double ___________() ; }
The final
says that what follows is a
constant, not a variable (variables are not allowed in interfaces.)
In fact, the final
can be omitted
since the identifier that follows will automatically be a constant.
The " = value " cannot be omitted.
The method declaration (in the second line) is public
by default.