package lab3; import java.io.*; public class lab3 implements Serializable{ B m_b; C m_c; public lab3() { D d = new D(); m_b = new B(d); m_c = new C(d); } public static void main(String[] args) { try { lab3 a = new lab3(); FileOutputStream fos; ObjectOutputStream oos; fos = new FileOutputStream("t.tmp"); oos = new ObjectOutputStream(fos); oos.writeObject(a); oos.flush(); fos.close(); FileInputStream fis; ObjectInputStream ois; fis = new FileInputStream("t.tmp"); ois = new ObjectInputStream(fis); lab3 a1 = (lab3) ois.readObject(); fis.close(); System.out.println("A:" + a1); System.out.println("B:" + a1.m_b); System.out.println("C:" + a1.m_c); System.out.println("D[B]:" + a1.m_b.m_d); System.out.println("D[C]:" + a1.m_c.m_d); } catch (IOException e) { System.out.println(e);} catch (ClassNotFoundException e) { System.out.println(e);} for( ; ; ); } class B implements Serializable { D m_d; B(D d) { m_d = d; } } class C implements Serializable { D m_d; C(D d) { m_d = d; } } class D implements Serializable { /* int d = 30; */ } }