This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

A possible typo in question (or answer) 36 in chapter 9 (OCP 17 - Practice Tests)

 
Ranch Hand
Posts: 67
5
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

With reference to question 36 in chapter 9 of the OCP Oracle Certified Professional Java SE 17 Developer Practice Tests: Exam 1Z0-829 (English Edition) book (Kindle edition), shown below.


In this question, an instance of Cereal has been serialized to disk, with the source object having a name value of CornLoops and sugar value of 5. What is the value of name and sugar after this object has been read from disk using the ObjectInputStream's readObject() method?



The question seems to start with a fact: "In this question, an instance of `Cereal` has been serialized to disk...".  The Bowl record does not implement Serializable, which means the bowl instance field must have been null (otherwise the initial part of the question is incorrect).  

Given that the bowl instance field must have been null during serialisation, we are able to deserialize the object, making option B correct.  Following are all options available for completeness.

A. CaptainPebbles and 10
B. CornLoops and 0
C. SugarPops and 10
D. SugarPops and 2
E. CornLoops and -1
F. None of the above



Any thoughts?
 
Saloon Keeper
Posts: 15276
350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want our thoughts, you'll have to share more context. We don't know what the Cereal class (or any of its components) looks like, nor what the question is asking.
 
Albert Attard
Ranch Hand
Posts: 67
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.

I made the wrong assumption that everyone in this chat group has the book.

This is the Cereal class.



I have added the setters and toString() methods as these were omitted, I believe for brevity.

The following code shows how to reproduce this.



The above example works and prints the output matching option B.
 
Stephan van Hulst
Saloon Keeper
Posts: 15276
350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, so what's the problem?
 
Albert Attard
Ranch Hand
Posts: 67
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the answer is incorrect.

The book says option F is the correct answer, while I believe it should be option B.
 
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok that one gets TWO cows. Added to errata.

You broke our question . Seriously though, you are right. We were not assuming it would be null. But then it fails on writing rather than reading and that breaks the question.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic