title: What is the purpose of marker interface?
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/4540820/marker-interface">marker interface</a><br>
    <a href="https://stackoverflow.com/questions/1023068/what-is-the-purpose-of-a-marker-interface">What is the purpose of a marker interface?</a>  </p>
  </blockquote>
  
  
  
  <p>I know what is marker interface - An interface with no methods.
  Example: Serializable, Remote, Cloneable.</p>
  
  <p>I am wondering what is the purpose of marker inteface. This is my understanding:-</p>
  
  <p>Basically it is just  to identify the special objects from normal objects. Like in case of serialization , objects that need  to be serialized must implement serializable interface  and  down the line writeObject() method must be checking somewhere if it is a instance of serializable  or not. As far as i think ,Thats the only purpose for which writeObject   using interface serializable(marker interface). Right? or jvm provides some extra functionality too on the basis of serializable interface?</p>
  
  <p>Similar kind of logic is true for cloneable interface.</p>
  
  <p>Now lets see how it is useful.</p>
  
  <p>Lets say in a application we have 1000 value objects.We want to serialize only 100 specific objects . Now JDK has said that programmer role is just to mark the object as special with marker interface in this case its serializable interface.Now JDK will take care of that which object to serialize or not?</p>
  
  <p>Yes we  could achieve this kind of behaviour with some kind of bollean flag . but that
  would be a bad approach.</p>
  
  <p>Similarily we can say in case of user defined marker interface , we can distinguish special objects with help of marker interface.Like we can use instance of operator to determine if it is a instance of that particular interface . If yes proceed in case of No throw some exception.</p>
  
  <p>Please let if above understanding is correct?</p>