This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
A question from the K&B 6 mock exam (Q30 of 2nd mock exam): Which are true? (Choose all that apply.) A. To implement java.io.Serializable, a class must implement two methods. B. When an object is serialized, if it has references to other objects, those objects must be serializable. C. A serialized object can be deserialized only by the same JVM which was used to serialize it. D. The values in the instance variables marked volatile will not survive serialization and deserialization.
The correct answer (according to the exam) is B.
However, to my thinking, if an object has references to other objects, those objects need not be serializable if they are marked transient. "Those objects must be serialzable" is therefore not true. Perhaps I differ on what "must" means in this context. Or perhaps the questioner meant "To serialize all members of an object" when they said "When an object is serialized".
Regardless, the problem here is not with my understanding of serialization, but rather my understanding of the meaning of the question. I'm not having trouble deciphering Java code, I'm having trouble deciphering the intent of the questioner's English. And this worries me since I have no way of preparing for that.
Have people encountered other questions like this, where figuring out the meaning of the questions themselves is the hurdle you have to overcome? [ December 20, 2008: Message edited by: Jamie MacDonald ]
I share your view. I have encountered a number of ambiguous questions myself, and usually I find that when a question like that comes up you have to think simple.
I'll give you an example (from Enthuware SCJP6, and I am paraphrasing):
When a continue statement is found in a while loop, that causes the current iteration of the loop to finish, and the next iteration to start.
Answer 1: True Answer 2: False
I answered False, because when a continue statement is found, that causes the current iteration of the loop to finish, the while boolean condition to be checked, and if it is satisfied, the next iteration of the while loop to start. Now, do you consider the checking of the boolean condition to be part of the iteration? I suppose you can look at it both ways, but the point is that I complicated myself too much and I gave the wrong answer.
I wonder if there are questions of this sort in the actual exam. I hope not. [ December 20, 2008: Message edited by: Ruben Soto ]
All code in my posts, unless a source is explicitly mentioned, is my own.