Home CPSC 240

Lab 5: Memory

 

Objective

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


 

Task

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.


 

Submitting

When you are done, please email your explanation to ifinlay@umw.edu. You can send it in the message of your email, or attach it as a document.

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