CSC 216/s08/feign ignorance

From Expertiza_Wiki
Revision as of 07:23, 27 March 2008 by Jcsmith2 (talk | contribs)
Jump to navigation Jump to search

Cloning and the Object Superclass

A group exercise to help clarify the ambiguities related to cloning objects in Java.

The problem

Cloning objects in Java is not as straightforward as one might expect. Every class inherits a set of standard methods, including the clone() method from the Object superclass, but by default this method is protected. This prevents instances of classes outside of the object's package from cloning that object (unless it is a subclass of that object). By default, when a class implements the Cloneable interface, a call to the clone() method creates a shallow copy of that object, which basically allocates memory for a new instance and copies the memory allocated for the current object. This is ideal for ...

Participants and props

How many students will participate? What else do you need (e.g., old tennis ball, Powerpoint slides, software).

The script

Describe how to do your exercise.

References

Formatting Resources

Formatting Help Guide from MetaWiki