This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SERIALIZABLE CLASSES

 
ZEESHAN AZIZ
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One very frequent question I have come across in Greens Exam is that whether class
xyz is serializable/cloneable.
I am not clear which classes are serializable, or which are cloneable. Is their any thumb
rule etc
 
Ricardo Polero
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A class is serializable (persistent in a flat file) if implement serializable or externizable interface.
Clonable is a deep/shadow copy in memory of the INSTANCE of a class (object)
I hope this light you
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zeeshan,
Not sure there is a quick rule of thumb I took a look in the class libraries and spotted the following:
Classes implementing Serialiazable:

  • File
  • ObjectStreamClass
  • Throwable (all Errors and Exceptions inherit from Throwable so they are all serializable)
  • All the wrapper classes: Boolean, Byte, etc
  • String and StringBuffer
  • the Collection classes

  • For Cloneable, all arrays, and most, if not all the Collection classes.
    Hope that helps.
    ------------------
    Jane Griscti
    Sun Certified Programmer for the Java� 2 Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic