title: How java serialization works internally?
body: <p>I was reading about Java serialization and came to know that if Serializable interface is implemented then class is serialized.</p>
  
  <p>But Serializable is a marker interface. Then how does JVM know with which methods serialization or de-serialization should be done?</p>
  
  <p>As per my understanding the methods declared in an interface are called via polymorphism.</p>
  
  <p>I would give an example below to examplain my question.</p>
  
  <pre><code>    public class MySerializable implements Serializable{
  
      public void serialize(){
  
        //Some code to serialize to a file output stream.
      }
  
      public void deSerialize(){
  
        //Some code to de-serialize to a file input stream.
      }
  
  
  }
  </code></pre>
  
  <p>So now how JVM will call the methods serialize / deSerialize?</p>
  
  <p>And if I have to call them manually via code then why compiler should be let known that Serializable interface is implemented?</p>