• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Chapter 6 K&B Self Test Question 12 Help

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

transient Wheels w = new Wheels();
Then Dodge would be serializble?


Yes.

Also what if Wheels for some reason was a subclass of Car then everything would also be fine?


Like
Yes.

I think ...

John
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic