A good answer might be:Both. Usually objects in the world can be regarded in several ways. | ||
InterfaceOne of the advantages of object oriented programming is that software objects are similar to "real world" objects, and so are familiar to programmers and users. This makes programming easier and more reliable. A real world object often is a member of several different classes at the same time. But a Java object is an instantiation of just one class, which is a child of just one parent. A Java interface is used when a child class has several different aspects. An interface is a collection of constants and method declarations. The method declarations do not include an implementation (there is no method body.)A child class that extends a parent class can also implement an interface to gain some additional behavior. Here is what an interface definition looks like, in general:
This looks somewhat like a class definition. But, unlike a class, an interface cannot be instantiated. A class definition implements an interface like this:
The class always extends one parent but may implement several interfaces. | ||
QUESTION 2:What is a method declaration without the implementation? Click Here after you have answered the question |