On page 450 of the OCP II Java 8 Study Guide by Jeanne Boyarsky and Scott Selikoff I encountered a possible issue in question 21.
Question 21 says: "Assuming the following class has proper public getter/setter methods for all of its private fields, which of the following fields will always be null after an instance of the class is serialized and then deserialized? (Choose all that apply.)"
Correct answers (page 567) given are options A and C (name and age).
There's also an option B (tail). The answer on page 567 says: B is incorrect because tail is not transient and could be set by a caller before being serialized.
But if a caller sets tail to a non-null value, depending on the class of tail being serializable, a NotSerializableException could be thrown.
So there's my problem: As soon as you allow a caller to set tail before serialization, answer G could be right as well.
Granted, I should have read better. Even when an exception was thrown then the premise would not even be true ("after an instance of the class is serialized and then deserialized") since serialization would have failed.
Thanks anyway for your help!
yeah, but ... what would PIE do? Especially concerning this tiny ad: