This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding clone() in Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding clone() in Object" Watch "Overriding clone() in Object" New topic

Overriding clone() in Object

Sven Thor
Ranch Hand

Joined: Jan 31, 2004
Posts: 34
When you override clone() from Object its visibility should be raised from protected to public. Is the reason for this simply to allow also non-subclasses in other packages to clone your objects ? Or is there another reason for this ? For classes in the same package I can not see that it matters if the clone() implementation is public or protected
I know that since clone() is protected in Object, subclasses of Object can only invoke clone() on its own objects, and not any object. That is not my question.
pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
is clone() included in SCJP1.4??? cause its never been mentioned any certification books.....plz let me know 10x

Thanks,<br />Pallavi
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
clone() will continue as much as "this" from java perspective.
[ April 07, 2004: Message edited by: Kishore Dandu ]

SCJP, blog
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

its in 1.4

Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
jQuery in Action, 2nd edition
subject: Overriding clone() in Object
Similar Threads
protected methods of java.lang.Object
Object Cloning
clone problems
Why PROTECTED method in class Object?
clone() method