• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cloneable interface!!

 
Ashok Paulraj
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 330
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Jim Crawford
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...its likely to be a shallow copy though where lists are involved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic