[SOLVED] CMSC 203 Lab 5

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

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 ==?

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.