The answer lies in the basics of
Java. We know that interfaces define pure behavior, and classes define state as well as behavior. Now, Interfaces are used to specify the behavior of classes derieved.
There are scenarios when we don't want the user to do any specific coding, but we want that behaviour to be achieved. In these cases the Marker Interface comes into action. When we implement a marker interface, we get the features incorporated in it, without writing any piece of code. Another important keyword in this context is the Tagged Interface.
Now, examples of Marker interface are
- java,lang.Cloneable
- java,io.Serializable
- java.util.EventListener
All, these are Marker interfaces and once you implement them in your class you get the appropriate behaviour.
When a .clone() call is made on an object the Java compiler makes sure that the class implements the Cloneable interface.
Hope this helps.
