Starting from:

$34.99

CMSC203 Lab 5-Memory Mapping Solution

Memory Mapping

1. Draw the memory map of the following variable int w and one-dimensional array of type int.
int w = 14;
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:


3. Draw the memory map of the following one-dimensional 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 a shallow copy of the following in code. (Assume the five animal objects are already instantiated.)
Animal[] zoo = {tiger1, elephant2, giraffe3, monkey4, ape5}; Animal[] copy;




b. Draw the memory map.
Stack: Heap:

5. a. Write the deep copy of the following in code.
Animal[] zoo = {tiger1, elephant2, giraffe3, monkey4, ape5};
Animal[] copy;





b. Draw the memory map.
Stack: Heap:


6. What is garbage collection? Where does it happen?




7. What is the difference between the two operators, equals() and ==?

More products