Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Which one is eligible for garbage collection Ans is a2.b2 but any one please tell me why

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Which one is eligible for garbage collection Ans is a2.b2 but any one please tell me why

    class Beta { }
    class Alpha { static Beta b1;
                      Beta b2;
                    }
    public class Tester 
    {
         public static void main(string[] args)
          {
              Beta b1 = new Beta();
              Beta b2 = new Beta();
              Alpha a1=new Alpha();
              Aplha a2=new Alpha();
              a1.b1=b2;
              a1.b2=b1;
              a2.b2=b2;
              a1=null;
              b1=null;
              b2=null;
          }
    }
    Last edited by helloworld922; June 12th, 2013 at 01:54 PM. Reason: please use [code] tags


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,443
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 544 Posts

    Default Re: Which one is eligible for garbage collection Ans is a2.b2 but any one please tell me why

    We aren't just going to do your homework for you.

    What do you think the answer is? What does your research show?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Does garbage collection occurs in PERM Area of Java Heap ?
    By javabuddy in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 21st, 2011, 11:27 PM
  2. [SOLVED] FileReader.read() reads garbage
    By Hackworth in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: August 27th, 2010, 01:06 PM
  3. Java Garbage Collection and destructors
    By riddhik84 in forum Java Theory & Questions
    Replies: 5
    Last Post: October 1st, 2009, 09:06 AM
  4. Garbage Collection?
    By kalees in forum Collections and Generics
    Replies: 6
    Last Post: September 23rd, 2009, 03:07 AM
  5. Java annotation
    By abhishekraok2003 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 17th, 2009, 12:55 AM