24) Interfaces

Need of Interfaces:

Example:

Suppose we have two classes Programmer and Manager both of them extend some common feature from Employee class.Now let say we have the below requirement/behavior to implement

That's the reason why interface are needed

Code:

Output:

UML :

Defining Interfaces:

Types of methods in an interface :

Rules to implement Interface:

A class can implement multiple interfaces:

Rule 1:

Rule 2:

Multiple inheritance is possible using Interfaces:

Properties of a member of an interface:

Last updated

Was this helpful?