Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. 3 points] For the following code snippets, fill in the box and pointer diagra

ID: 3756692 • Letter: 1

Question

1. 3 points] For the following code snippets, fill in the box and pointer diagrams to show The double boxes represent IntList objects (see definition on page 2), with the left box containing the head field. Show also any output produced. You may not need all the boxes or output lines provided (b) The vertical stack of boxes represents an array object. IntList a - IntList.list (65, 82, 77); IntList0 b new IntList [3]; Write Output Here: b[0] = a.tail.tail; b[0].tail -new IntList (66, null); b[2]b[0].tail; System.out.println(b [2].head); System.out println((b[1].head + 4)); a: b:

Explanation / Answer

As per the given operations perfomred on the given IntList

a = {65, 82, 77}

b[1] = a -- > i.e b[1] = {65, 82, 77}

b[0] = a.tail.tail; --> i.e a.tail={77} and a.tail.tail={77} then b[0] = 77

b[0].tail= new IntList(66, null); --> i.e b[0] will be overriden which is b[0]={66, null}

b[2]=b[0].tail; --> i.e b[0].tail is null and will be assigned to b[2]=null

The output for the following would be,

System.out.println(b[2].head); --> o/p is null

System.out.println(b[1].head+4); --> o/p is 69