title: Serialization issue if the parent does not have a no-arg constructor
body: <p>I'm trying my best to understand this concept. But I am not able to figure out this thing: </p>
  
  <p>If the parent has no no-arg constructor and also the parent does not implement Serializable interface how can a serialize a child class?</p>
  
  <p>Parent.java</p>
  
  <pre><code>public class Parent {
      private String parentString;
      public Parent(String parentString) {
          this.parentString = parentString;
          parentString = "Parent";
      }
      public String getParentString(){
          return parentString;
      }
  }
  </code></pre>
  
  <p>Child.java</p>
  
  <pre><code>public class Child extends Parent implements Serializable{
      private String childString;
      public Child(String childString) {
          super(childString);
          this.childString = childString;
      }
      public String getChildString(){
          return childString;
      }
  }
  </code></pre>
  
  <p>TestSerialization.java</p>
  
  <pre><code>public class TestSerialization {
  
      public static void main(String[] args) throws IOException, ClassNotFoundException{
  
      Child child = new Child("Child");
      FileOutputStream fos = new FileOutputStream(new File("file.ser"));
      ObjectOutputStream oos = new ObjectOutputStream(fos);
      oos.writeObject(child);
      oos.close();
  
      FileInputStream fis = new FileInputStream(new File("file.ser"));
      ObjectInputStream ois = new ObjectInputStream(fis);
      Object obj = ois.readObject();
      ois.close();
  
      Child castChild = (Child) obj;
  
      System.out.println(castChild.getParentString());
      System.out.println(castChild.getChildString());
  
  
  }
  
  }
  </code></pre>
  
  <p>It gives me an Exception while reading the object, saying <code>java.io.InvalidClassException: test.Child; no valid constructor</code>. How can a serialize such objects?</p>