/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.text.MessageFormat;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static class A {
		public final int a;
		
		public A() {
			this.a = 0;
			System.out.println(
					MessageFormat.format("new A() constructor is called to create an instance of {0}.",
					getClass().getName()));
		}

		public A(int a) {
			this.a = a;
			System.out.println(
					MessageFormat.format("new A(int) constructor is called to create an instance of {0}.", 
			        getClass().getName()));
		}
	}
	
	public static class B extends A implements Serializable {
		public final int b;

		public B(int a, int b) {
			super(a);
			this.b = b;
			System.out.println(
					MessageFormat.format("new B(int, int) constructor is called to create an instance of {0}.",
					getClass().getName()));
		}

		@Override
		public String toString() {
			return "B [a=" + a + ", b=" + b + "]";
		}
		
		
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		B b1 = new B(10,20);

        System.out.println(b1);
        
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try(ObjectOutputStream oos = new ObjectOutputStream(bos)) {
            oos.writeObject(b1);
        }

        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        try (ObjectInputStream ois = new ObjectInputStream(bis)) {
            B b2 = (B)ois.readObject();
            System.out.println(b2);
        }
	}
}