Question: Title: Array object reference and memory structure analysis Given the following code snippet: java Point [ ] arr = new Point [ 4 ] ;

Title: Array object reference and memory structure analysis Given the
following code snippet:
java
Point[] arr = new Point[4];
arr[0]= new Point(30,40);
arr[1]= new Point(50,60);
arr[2]= new Point(70,80);
\operatorname { a r r [3]= ~ n u l l ; }
Point[] arr2= arr;
arr2[1].setX(10);
arr2= new Point[3];
arr2[0]= arr[2];
arr2[1]= new Point();
arr2[1].setY(-10e);
arr[0].setX(arr[0].getX()+5);
Questions:
Draw a diagram of the memory structure after arr 2=arr; and explain the relationship
between arr2 and arr.
What happens to the content of arr[1] after executing arr2[1].setx(10)? Why?
What is the relationship between arr2 and arr after executing arr2=new Point[3]? Draw
a new diagram of the memory structure.
What are the contents of the arrays pointed to by arr and arr2 respectively after the code
is executed? Please describe and explain the changes in memory in detail. Part 2:
Title: Array object reference and memory

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!