posted 13 years ago
The code from the K&B book is as follows:
The question asked is: Instances of which class(es) can be serialized? (Choose all that apply.)
A. Car
B. Ford
C. Dodge
D. Wheels
E. Vehicle
Answer Given: A and B are correct. Dodge instances cannot be serialized because they "have" an instance of Wheels, which is not serializable.
My question finally...
I agree with the answer and explanation given. Hypothetically speaking, if we were to add a transient keyword into the mix at line 7: ie.
Then Dodge would be serializble?
Also what if Wheels for some reason was a subclass of Car then everything would also be fine?