Is it correct? A good answer might be:No. Variables (such as y) cannot be put in an interface. Only constants and methods. | |||
Implementing an InterfaceA class definition must always extend one parent, but it can implement zero or more interfaces:
The body of the class definition is the same as always. However, since it implements an interface the body must have a definition of each of the methods from the interface. The class definition can use access modifiers as usual. Here is a class definition that implements three interfaces:
Now BigClass must provide a method definition for every method in each of the interfaces. Any number of classes can implement the same interfaces. Here is another class definition:
| |||
QUESTION 4:Is the above class definition correct? Click Here after you have answered the question |