Exam 1z0-829 All QuestionsBrowse all questions from this exam
Question 41

Given the Product class:

and the Shop class:

What is the result?

    Correct Answer: B

    The Product class implements Serializable, and the price field is marked as transient, meaning it won't be serialized. When the Product object is deserialized, the readObject method in the Product class sets the price field to the static averagePrice value, which is 2.99. Hence, when the toString method is called, it returns the description 'Cookie', the price field which has been set to 2.99, and the static averagePrice which is also 2.99. This means the printed output would be 'Cookie 2.99 2.99'.

Discussion
supersquaxOption: B

B correct, verified in online compiler!

xplorerpjOption: B

B is correct