1Interface is the concept of encapsulation
– The implementation can change without affecting the caller of the interface
– The caller does not need the implementation at the compile time
● It needs only the interface at the compile time
● During runtime, actual object instance is associated with the interface type
2. Example:
– Class Line and class MyInteger
● They are not related through inheritance
● You want both to implement comparison methods
– checkIsGreater(Object x, Object y)
– checkIsLess(Object x, Object y)
– checkIsEqual(Object x, Object y)
– Define Comparison interface which has the three abstract methods above
3. A class can implement multiple interfaces while it can extend only one class