An interface defines a set of method which must be implemented. It says nothing on how they are implemented. This is where the class definition comes in, since it defines how these methods are implemented.
Thus, when you call a class which implements a particular interface, then you know, for sure, that you will find whatever set of methods the interface defines.
Interfaces are usually handy when you need to expose some endpoints to your application, without the need to expose the logic.
EDIT: As per your example, the printable
interface defines what behaviour should a class which implements it expose, in this case print
.
This will allow you to do something along the lines of printable p = new A(); p.print();
.
Assuming you have something which yields an object which implements the printable
interface, then, whoever is calling that method will not need to bother what is the actual implementation of the print
method. The interface makes sure that whatever you are returning, will contain an implementation of that method.