Win a copy of Head First Go this week in the Go 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Serialization and deserialization  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


If an instance of class Beagle is created, then Serialized, then deSerialized, what is the result?

This is a question from Kathy Sierra Total Tester.  Answer is give as ada.

I am doubtful about the answer. Can any one please explain the correct answer and reason?
 
Marshal
Posts: 63485
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Work out which constructors are called in object creation and serialisation.
 
SwapanB Biswas
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if  Beagle object is created, super class constructor Dog() is called which in turn call its super class constructor Animal(). So out put is ad. Now during destabilization , Beagle constructor is not called as Beagle is serialized(since its super class Animal is serialized). But Animal constructor is called as Animal is not serialized.So it prints a.
So out put is ada.

Is it the way it's working?
 
Campbell Ritchie
Marshal
Posts: 63485
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes


I think.
 
Marshal
Posts: 24198
54
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

SwapanB Biswas wrote:Is it the way it's working?



Seems to me it shouldn't take long to just run that code and see what happens.
 
SwapanB Biswas
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran the code and worked in that way. Thank you.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!