This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SERIALIZABLE CLASSES Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)


Ranch Hand

Joined: Jan 15, 2001
Posts: 162
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

Joined: May 18, 2001
Posts: 128
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

Joined: Aug 30, 2000
Posts: 3141
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

Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
I agree. Here's the link:
Similar Threads
Object Reference Conversion
Interfaces with no body
why it is Serializable and Cloneable are more difficult to implement when inheritance is present
Dan's new Collections Questions
Marker Interface