Interface is an empty class which contains only the declaration of methods. So any class which implements this interface must contain the declared functions in it. So, interface is nothing but a strict ruling, which helps to extend any class and strictly implement all methods defined in interface. A class can use any interface by using the implements
keyword. Please note that in interface you can only declare methods, but you cannot write their body. That means the body of all methods must remain blank.
So why is an interface necessary, you might ask? One of the reasons is it implies strict rules while creating a class. For example, we know that we need to create some driver classes in our application, which can handle DB operations. For MySQL, there will be one class, for PostgreSQL there will be another, For SQLite, another one and so forth. Now your developer team has three developers, who will separately create these three classes.
Now how will it be if each of them implements...