About Question enthuware.ocpjp.v8.2.1390 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
lexer24
Posts: 6
Joined: Wed Jun 22, 2016 8:06 am
Contact:

About Question enthuware.ocpjp.v8.2.1390 :

Post by lexer24 »

Hi,

Why description of question strictly says - "3. To serialize the object using the default behavior, you must call objectOutputStream.defaultWriteObject();. This will ensure that instance fields of Portfolio object are serialized."?

From https://docs.oracle.com/javase/8/docs/p ... .html#a861:
The class's writeObject method, if implemented, is responsible for saving the state of the class. Either ObjectOutputStream's defaultWriteObject or writeFields method must be called once (and only once) before writing any optional data that will be needed by the corresponding readObject method to restore the state of the object; even if no optional data is written, defaultWriteObject or writeFields must still be invoked once. If defaultWriteObject or writeFields is not invoked once prior to the writing of optional data (if any), then the behavior of instance deserialization is undefined in cases where the ObjectInputStream cannot resolve the class which defined the writeObject method in question.

For 4. point docs.oracle gives similar answer.

Best regards,
Aleksei

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1390 :

Post by admin »

You are right. It should say defaultWriteObject() or writeFields. Fixed.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests