Interfaces
| |||
Interfaces are the next level of abstraction. An
interface is like a class with nothing but However, unlike a class, an interface can be added to a
class that is already a subclass of another class. Furthermore an
interface can apply to members of many different classes. For instance you
can define an
You might want to use this interface on many different
classes, cars among them but also for clothes, food, electronics and moore.
It would be inconvenient to make all these objects derive from a single
class. Furthermore, each different type of item is likely to have a
different means of calculating the tariff. Therefore you define an Import
interface and declare that each class implements Import .
The syntax is simple. The You can declare many different methods in an interface.
These methods may be overloaded. An interface can also have fields, but if
so they must be | |||
|