I am thankful to all for reading my blogs and correct my mistake and suggest me much better about oops.

I am going to discuss interface role in oops.

We already learned objects define their interaction with the outside world through the methods that they expose.

Methods from the objects interface with outside world, the buttons on the front of your TV set, for e.g.,

are the interface b/w you & the electrical wiring on the other side of its plastic casing. You press the "power" button to turn the television ON & OFF.

E.g. using interface.

interface SessionIDCreator extends Serializable, Cloneable {

        String TYPE = "AUTOMATIC";
        int createSessionId();
    class SerialSessionIDCreator implements SessionIDCreator {
        private int lastSessionId;
        public int createSessionId() {
            return lastSessionId++;

In above example of an interface in Java, SessionIDCreator is an interface while SerialSessionIDCreator is an implementation of the interface.

  Modified On Feb-23-2018 01:11:01 AM
  1. Ankita good analogy for interfaces!!

    But you must explain here how we use interfaces in our implementation and facilitates our OOPs designs with interfaces

Leave Comment