Container with transient fields

Report a typo

Here is a declaration of the Container class.

class Container implements Serializable {
    private static final long serialVersionUID = 5L;

    private transient String name;
    private transient long value;

    Container(String name, long value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public long getValue() {
        return value;
    }
}

What is the result of the following code execution?

Container container = new Container("one", 1);
String fileName = "container.data";

FileOutputStream fos = new FileOutputStream(fileName);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(container);
oos.close();

FileInputStream fis = new FileInputStream(fileName);
BufferedInputStream bis = new BufferedInputStream(fis);
ObjectInputStream ois = new ObjectInputStream(bis);
Container obj = (Container) ois.readObject();
ois.close();

System.out.println(obj.getName() + " " + obj.getValue());
Select one option from the list
___

Create a free account to access the full topic