Advertisement
Kvarz

Head First Garbage collector exercise

Aug 17th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. //which of the lines of code on the right, if added to the class on the left at point A,
  2. //would cause eactly one additional object to be eligible
  3. public class GC {  
  4.   public static GC dostuff();  
  5.      GC newGC = new GC();  
  6.      doStuff2(newGC);  
  7.      return newGC;  
  8.   }  
  9.  
  10. public static void main(String [] args) {  
  11.   GC gc1;  
  12.   GC gc2 = new GC();  
  13.   GC gc3 = new GC();  
  14.   GC gc4 = gc3;  
  15.   gc1 = doStuff();  
  16.  
  17.   // call more methods  
  18.  
  19. gc2 = null;
  20. gc1 = null;
  21. gc1 = gc4;
  22. }  
  23.  
  24. public static void doStuff2(GC copy GC) {  
  25.   GC localGC  
  26.  }  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement