Home CPSC 240

Lab 4: Memory



To work on understanding the way that memory works in Java.



For this lab, you will be running the Memory.java program. This program makes "Thing" objects. A Thing contains an integer inside it. When you print it, it prints the number it's currently storing, and its memory address.

The main method makes a few Thing objects, and some references to them. The program doesn't do anything really useful, but does some tricky things with the objects.

For this lab, you will go through the program and for each commented section (of which there are six), write a paragraph explain what that section is doing. If it's making an object on the heap, say so. If it is making a reference on the stack, say so. If it's pointing a reference at an existing object, say so.

Be as explicit as you can. Each section should have 3 to 5 sentences explaining what is going on. Be sure to mark which section your paragraphs are talking about.



When you are done, please submit your explanation as a file upload to the assignment in Canvas.

Copyright © 2021 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.