"Constructor of the class for an object being deserialized in never invoked."
I thought the question missed the word "is" (instead of misspelling it) to read like this:
Constructor of the class for an object being deserialized in IS never invoked.
I took into account if an object being serialized had members(maybe inherited) that were objects that aren't serialized, their constructors would run.
so I did not choose this selection.
so I chose the answer:
While serializing an object, only those objects in the object graph that implement Serializable are serialized.
I understand the explaination for the answer and I think that it makes it more of a correct answer:
"If the object graph contains non-serializable objects, an exception is thrown and nothing is serialized."
This is not true if the transient modifier is used.
I must admit though that I have never seen the term "object graph" before.
- Site Admin
- Posts: 8958
- Joined: Fri Sep 10, 2010 9:26 pm
Option 4 is correct. If an object is indeed being deserialized, its constructor will not be called. If a reference is transient, then the referenced object it is not really being deserialized at all.
The 5th option, "While serializing an object, only those objects in the object graph that implement Serializable are serialized." is wrong because Object that are not serializable are either ignored (if the references to them are marked as transient) or cause an exception to be thrown.
Explanation has been enhanced to explain it better.
Thank you for the feedback!
Users browsing this forum: No registered users and 1 guest