Multiple choice technology programming languages

What is the output for the below code ? public class A { public A() { System.out.println("A"); } } public class B extends A implements Serializable { public B() { System.out.println("B"); } } public class Test { public static void main(String... args) throws Exception { B b = new B(); ObjectOutputStream save = new ObjectOutputStream(new FileOutputStream("datafile")); save.writeObject(b); save.flush(); ObjectInputStream restore = new ObjectInputStream(new FileInputStream("datafile")); B z = (B) restore.readObject(); } }

  1. A B A

  2. A B A B

  3. B B

  4. A B

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When creating B, constructors chain: prints 'A' then 'B'. During deserialization, constructors are NOT called for the serialized object itself, but the superclass no-arg constructor IS called for the non-serializable superclass A, printing 'A' again. Output: 'A B A'.