An
interface is a template that contains only the signature of methods.
The signature of a method consists of the numbers of parameters, the
type of parameter (value, reference, or output), and the order of
parameters. An interface has no implementation on its own because it
contains only the definition of methods without any method body. An
interface is defined using the interface keyword. Moreover, you cannot instantiate an interface. The various features of an interface are as follows:
- An interface is used to implement multiple inheritance in code. This feature of an interface is quite different from that of abstract classes because a class cannot derive the features of more than one class but can easily implement multiple interfaces.
- It defines a specific set of methods and their arguments.
- Variables in interface must be declared as public, static, and final while methods must be public and abstract.
- A class implementing an interface must implement all of its methods.
- An interface can derive from more than one interface.
No comments:
Post a Comment