Sumit Patil wrote:Marker interface are used to inform the compiler to add special behavior to the class implementing it.
E.g java.io.Serializable, tells the compiler that the objects of the class implementing Serializable interface can be serialized.
The compiler doesn't do anything special when it encounters a class that implements a marker interface*.
The built in marker interfaces (such as Serializable or Cloneable) are used by the JVM at runtime to decide if certain operations can be performed on an object.
But you can also create your own marker interfaces** which other parts of your code can then use to make decisions about how your code works.
* Unless you have declared a reference variable of the type of the marker interface, in which case the compiler may check if an object being assigned to this reference variable actually implements the interface. Although as the interface has no methods or fields I can't see any obvious reason for doing this.
** Although these days it is often recommended to use annotations rather than marker interfaces.