aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes serialization question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "serialization question" Watch "serialization question" New topic
Author

serialization question

Mike Mitchell
Ranch Hand

Joined: May 28, 2008
Posts: 37
hi. I was trying to whip something up to demonstrate that if a serializable object's parent is not serializable, than any inherited attributes will not be serialized.

However, when I run TestSerial below, I get the following exception. Having trouble understanding why. Anybody see the problem? If I make Food implement Serializable, it runs without exception.

Thanks much,
Mike




[ July 20, 2008: Message edited by: Mike Mitchell ]

SCJP 5, SCWCD 5
Don Solomon
Ranch Hand

Joined: Jul 20, 2008
Posts: 48
Hey Mike,
I had to add a default constructor to Food Class for your program to work; which I believe is a requirement for non-Serializable supers.

Anyone correct me if I am wrong.

Thanks
[ July 20, 2008: Message edited by: Don Solomon ]

Software development is an exercise in thinking not coding.
kaushik vira
Ranch Hand

Joined: Feb 01, 2007
Posts: 102
Ya.. Default constructor in parent class is mandatory if you are relaying on default serialization.


kaushik Vira
-------------------------------------
SCJP, Preparing SCWCD..
Mike Mitchell
Ranch Hand

Joined: May 28, 2008
Posts: 37
Thanks Don and Kaushik. That was it -- I needed a default constructor in the non-serializable super class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: serialization question
 
Similar Threads
compiler error saying method of serializable to be overridden
Deserializing
how FileOutputStream and ObjectOutputStream working here
Can't Understand How It Comes In Deserialization
how can we create new object using de-serlization in java ?