Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please need help in Serialization

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refer example on page 467 of Kathy Seirra and Bert Bates SCJP 6 Book. following is a part of the code from the example on the aforementioned page.

CODE LISTING




My question is that when we are serializing the dog object the serialization system calls the callback private writeObject method and passed it the ObjectOutputStream. but when we did os.writeInt(theCollar.getCollarSize()); how did it know which Dog's object Collar we are talking about, because we are not passing any dog reference explicitly or implicitly. ???
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That method is added to the Dog class. So there is an implicit Dog reference: this.
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a friendly reminder, it is good to learn more about object serialization/deserialization. But this objective has been removed from OCJP 6.0 exam.
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply Helen....but the topic Serialization is given in the SCJP 6 K&B book.......Can you please give me the source of updated objectives/syllabus for OCJP 6? thanks
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check for SCJP 1.6 (310-065) in our SCJP-FAQ_Objectives
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though this objective is removed from the exam, object serialization and deserialization are very useful in Java remote method invokcation (RMI).
When a client passes an object to a server over the network, the object has to be serialized. When the server receives it, it has to deserialize it.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic