What will be the output of the following program?
import java.io.*;
class SuperClass implements Serializable {
protected int salary;
protected SubClass subClass;
public SuperClass(SubClass subClass, int salary) {
this.subClass = subClass;
this.salary = salary;
subClass.value = salary;
}
public SubClass getSubClass() { return subClass; }
}
class SubClass {
int value;
public SubClass(int value) { this.value = value; }
public int getValue() { return value; }
}
public class ByteStream {
public static void main(String arg[]) throws IOException {
SubClass subClass = new SubClass(2500);
SuperClass superClass = new SuperClass(subClass, 5000);
System.out.println(superClass.getSubClass().getValue());
try {
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream("D:/hello.txt"));
outputStream.writeObject(superClass); // LINE A
outputStream.flush();
outputStream.close();
} catch (Exception e) { e.printStackTrace(); }
try {
ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream("D:/hello.txt"));
superClass = (SuperClass) inputStream.readObject(); // LINE B
inputStream.close();
System.out.println(superClass.getSubClass().getValue());
} catch (Exception e) { e.printStackTrace(); }
}
}