Question: 2) For each snippet of code below, draw an object diagram showing the memory organization once the snippet of code has been executed. The variables



2) For each snippet of code below, draw an object diagram showing the memory organization once the snippet of code has been executed. The variables p, and r are all of type Person (as defined in question 1)). Indicate on the object diagram any alias and any object that has been garbage- collected (see the given example). Example: Person p = new Person(); Person q = new Person(); Person r = new Person(); p=; r = 9; 4 = null; The execution of the above code is illustrated by the following object diagram: Person p Garbage collected * Person q null Person Garbage collected r r is an alias of p a) Person p = new Person(); Person q = new Person(); Person r = new Person(); p = 9; q=r; r = p; b) Person p = new Person(); Person q = p; p = new Person(); Person r = p; p = new Person(); q=p; p = new Person(); r= p; p = null; c) Person p = new Person(); Person q = new Person(); Person r = new Person(); p=; q = null; r=g; q=p
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
