Garbage Collection Quiz

Here’s a quick quiz about GC:
Q) At what point is x eligible to be cleaned up by the GC?

  <FIELDSET><LEGEND>Garbage Collection</LEGEND>
public void foo()
    Class1 x = new Class1();
    Class2 y = new Class2();

    y.Width = x.GetWidth();
    y.Height = y.Width;
    y.Color = "Red";

ANSWER: (highlight the black area to see answer)
<FONT style=”BACKGROUND-COLOR: #000000” color=#000000>After x.GetWidth() is executed</FONT>

See this post’s comments for explanation/discussion…

Tweet Post Share Update RSS

Hi, I'm John Papa. I author this blog, create courses for Pluralsight and am a Google Developer Expert and Microsoft Regional Director. I travel speaking at events and train technology thought leaders