CMSC 203 Lab 5 Memory Mapping

Verified

Added on  2019/09/16

|3
|284
|605
Homework Assignment
AI Summary
This document provides solutions to a memory mapping worksheet for CMSC 203 Lab 5. It includes drawing memory maps for one-dimensional and two-dimensional arrays of integers and strings, demonstrating shallow and deep copies of string arrays, and explaining garbage collection and the difference between the equals() method and the == operator. The solutions cover various aspects of memory management and object references in programming.
Document Page
1 | P a g e
CMSC 203 Spring 2016 - Lab 5
Memory Mapping Worksheet
1. Draw the memory map of the following one-dimensional array of type int.
int[] x = new int[8];
Stack: Heap:
2. Draw the memory map of the following two-dimensional ragged array of ints.
int[][] y = {{4, 8, 15}, {16, 23, 42, 10}, {8, 30}};
Stack: Heap:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
2 | P a g e
3. Draw the memory map of the following one-dimensional ragged array of type String.
String[] z = new String[4];
for (int i = 0; i < z.length; i++) {
z[i] = "element " + i;
}
Stack: Heap:
4. a. Write the shallow copy of the following.
String[] progLang = {"Algol", "Cobol", "Python", "Java", "Prolog"};
b. Draw the memory map.
Stack: Heap:
Document Page
3 | P a g e
5. a. Write the deep copy of the following.
String[] progLang = {"Algol", "Cobol", "Python", "Java", "Prolog"};
b. Draw the memory map.
Stack: Heap:
a.
b.
c.
d.
e.
f.
g.
h.
6. What is garbage collection? Where does it happen?
7. What is the difference between the two operators, equals() and ==?
chevron_up_icon
1 out of 3
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]