• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializable...

 
Priya Kannan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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!
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • 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
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Michael,
The link explains what serialization is; therefore, helps with the concept.
------------------
Jane Griscti
Sun Certified Java 2 Programmer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic