Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization 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
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Serialization and deserialization  RSS feed

 
Ranch Hand
Posts: 30
  • 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: 64115
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Work out which constructors are called in object creation and serialisation.
 
SwapanB Biswas
Ranch Hand
Posts: 30
  • 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: 64115
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes


I think.
 
Sheriff
Posts: 24369
55
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
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran the code and worked in that way. Thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!