This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

OCP II Study Guide possible erratum

 
Greenhorn
Posts: 3
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
For instance:

But:

So there's my problem: As soon as you allow a caller to set tail before serialization, answer G could be right as well.
 
author & internet detective
Posts: 39582
781
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But Option G can't be right because the question asks about "always". There's a scenario where it doesn't throw an exception.
 
Richard Osseweyer
Greenhorn
Posts: 3
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!