Question 13
Consider the code given below.
import java.io.*;class AutomaticGate implements Serializable { private boolean isOpen; private transient String location; private transient int gCode;
// Constructor to initialize instance variable public String toString() { return "isOpen=" + isOpen + ", location=" + location + ", gCode=" + gCode; }
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(gCode + 123); }
private void readObject(ObjectInputStream in) throws Exception { in.defaultReadObject(); gCode = in.readInt() - 123; }}public class Test { public static void main(String[] args) throws Exception { var fos = new FileOutputStream("GateData.txt"); var oos = new ObjectOutputStream(fos); AutomaticGate gate1 = new AutomaticGate(true, "North Entrance", 456789); oos.writeObject(gate1);
var fis = new FileInputStream("GateData.txt"); var ois = new ObjectInputStream(fis); AutomaticGate obj = (AutomaticGate) ois.readObject(); System.out.println(obj); }}What will the output be?