Question 13
Consider the code given below.
import java.io.*;class Laptop implements Serializable { private double price; private transient String model; private transient int serialNum; // Constructor to initialize instance variables public String toString() { return "price=" + price + ", model=" + model + ", serialNum=" + serialNum; }
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(serialNum + 100); }
private void readObject(ObjectInputStream in) throws Exception { in.defaultReadObject(); serialNum = in.readInt() - 100; }}public class Test { public static void main(String[] args) throws Exception { var fos = new FileOutputStream("Laptop.txt"); var oos = new ObjectOutputStream(fos); Laptop l1 = new Laptop(899.99, "Dell", 987654); oos.writeObject(l1);
var fis = new FileInputStream("Laptop.txt"); var ois = new ObjectInputStream(fis); Laptop obj = (Laptop) ois.readObject(); System.out.println(obj); }}What will the output be?