Question: How many singly - linked Node objects could the Java Virtual Machine mark as garbage after all the following statements have executed? Node n =

How many singly-linked Node objects could the Java Virtual Machine mark as
"garbage" after all the following statements have executed?
Node n= null;
n = new Node("T");
n.next = new Node("I", new Node("G"));
Node m=n.next.next;
m.next = new Node("E", new Node("R"));
n= null;
A.2
B.3
C.4
D.5
What I understand is n = T -> I -> G . Then m = n.next.next. So, m= G -> E -> R . Then n = null. So, the answser is 2 which is A. right? If it's wrong, please give me some details.
 How many singly-linked Node objects could the Java Virtual Machine mark

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 Databases Questions!