• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

ExamLab SCJP 6. Doubt with diagnose exam question 70

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I'm new to the forum and just tried the Diagnose Exam from ExamLab SCJP 6.
Question 70 it says:

How many objects are eligible for the Garbage collection, after executing statement "c.aob = null"?

public static void main(String args[]){
A a=new A();
A b=new A();
A c=new A();
a.aob=b;
b.aob=a;
c.aob=a.aob;
A d=new A().aob=new A();
c=b;
c.aob=null;
System.gc();
}

Correct answer is "2 objects", but after trying and trying and making diferent diagrams, I can see only one object eligible for gc.
Can somebody explain why there are two objects eligible?

P.D. Is it correct to paste a question from ExamLab in this forum or are them copyright protected or something like that? If so, I excuse in advance.
 
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rodolfo,

The answer to your question is in this thread.

You can post questions from ExamLab and other legal sources, but you must always provide the source with your post.
 
Rodolfo Landa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Ruben, now it's clear to me.

And sorry for starting a new Topic in a previously asqued and clarified question.I should use more caution in searching for info in the forum.

 
Ruben Soto
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem, Rodolfo. Everyone does it at some point or another. I was just pointing out that the Search functionality in this forum is actually useful (contrary to some other forums.)
 
reply
    Bookmark Topic Watch Topic
  • New Topic