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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Cloneable interface!!" Watch "Cloneable interface!!" New topic
Author

Cloneable interface!!

Ashok Paulraj
Ranch Hand

Joined: Jul 07, 2003
Posts: 78
Hello Every 1,
Do we need to study about cloneable interface for SCJP 1.4 ?. Anyway, I would like to get some basic info. about this and what we could do about that. I could see some questions in certain mock exams with clone() method calls on an object.
~ Shalini
dennis zined
Ranch Hand

Joined: Mar 07, 2003
Posts: 330
I'm not sure if its part of SCJP 1.4 but I've seen Dan's mock exams that include the Cloneable interface, like if ArrayList, HashMap, etc implements the Cloneable interface.
Just a brief background, a class that implements the Cloneable interface indicate that it is legal for to make a field-for-field copy of instances of that class. Invoking Object's clone method on an instance that does not implement the Cloneable interface results in the exception CloneNotSupportedException being thrown.
For example, arrays implement the Cloneable interface:


SCJP 1.4<br />SCWCD 1.4
Jim Crawford
Ranch Hand

Joined: Sep 08, 2002
Posts: 127
...its likely to be a shallow copy though where lists are involved.


<img src="cool.gif" border="0"> <img src="graemlins/beerchug.gif" border="0" alt="[beerchug]" /> <br />SCJP 1.4
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cloneable interface!!