• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Serializable...

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
It's been said that the subclass of a class that implements the serializable interface will work without flashing errors only if the base class has a default constructor.(And I thought an implicit default constructor would be created if the subclass doesn't define one)
Hey, can anybody help me with this "serializable" concept.
Thanks!
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Priya,
See Sun Tech Tip: Serialization and Transient Variables.
Hope that helps.
------------------
Jane Griscti
Sun Certified Java 2 Programmer
"When ideas fail, words come in very handy" -- Goethe
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused; how does the text at that link explain the so-called need for an (explicit?) default contructor in the class that implements Serializable.
So far as I know, there's no such requirement.
 
Priya Kannan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the link Jane.
I really didn't expect a reply from the author of one of my favourite books!
As for the question, I'll take your word for it.Actually I came across this Qn in one of the mock exams(having trouble in finding out which!).It looked something like this,
class Base
{
int i;
}
class Derived extends Base implements java.io.Serializable
{
float f;
}
Maybe I misunderstood the context of implicit & explicit constructors,but I'm positive that it stressed the need for a constructor in the Base class if the Derived was to implement Serializable without announcing errors.So Mike,can you please help me construct the Qn. first and then provide an answer perhaps?
Thanks a ton!

 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,
The link explains what serialization is; therefore, helps with the concept.
------------------
Jane Griscti
Sun Certified Java 2 Programmer
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic