Interview Question on Java finalize method
<p>I have came across difficult (for me) Java interview question on finalize method. Suppose you have given finalize method as shown below:</p>

<pre><code>public void finalize()
{
     a.b = this;
}
</code></pre>

<p>Now the following object scenario is given.</p>

<p><img src="http://i.stack.imgur.com/WQoZb.png" alt="enter image description here"></p>

<p>How would you solve this problem? If A was not referring to B then this problem could be easier as GC will run, it will collect B and call finalize for B but here A is referring B so its difficult. How finalize will work in this scenario?</p>

<p>Any ideas? Thanks in advance </p>
