Draft - Object Copying and Memory
Authoring skeleton - not a student assignment
Three short topics
- Java passes copies of reference values; distinguish aliasing from copying.
- Implement a copy constructor and compare shallow and deep copies.
- Explain reachability, lifetime, and garbage collection.
PBL context
Observe AssignmentQueue’s working, waiting, and completed lists. Prototype an independent snapshot without changing production persistence.
Implementation layers to author
- Trace two references to one queue.
- Copy the queue and its mutable lists.
- Test that changing the snapshot does not alter the original.
Evidence checklist to author
Include empty and populated queues, reference reassignment, and mutation isolation. Link the existing object-storage and scope lessons. Do not describe Java as pass-by-reference.
Publication checklist
Author examples, a CodeRunner exercise, and verifiable assessment checks. Then assign courses.csa.week, remove draft/hide flags, and enable submissions as appropriate.
Code Runner Challenge
Authoring draft - object copying exercise is not ready
View IPYNB Source
// CODE_RUNNER: Authoring draft - object copying exercise is not ready
public class CopyingDraft {
public static void main(String[] args) {
throw new UnsupportedOperationException("Draft: author the copying exercise and tests before publication.");
}
}
CopyingDraft.main(null);
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...