import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; class Player { Player() { System.out.print("p"); } } class MainClass extends Player implements Serializable { MainClass() { System.out.print("c"); } public static void main(String[] args) { MainClass c1 = new MainClass(); try { FileOutputStream fos = new FileOutputStream("play.txt"); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(c1); os.close(); FileInputStream fis = new FileInputStream("play.txt"); ObjectInputStream is = new ObjectInputStream(fis); MainClass c2 = (MainClass) is.readObject(); is.close(); } catch (Exception x) { } } }