Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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
Devaka Cooray
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Jeanne Boyarsky
Tim Cooke
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Bartenders:
Forum:
Programmer Certification (OCPJP)
kathy sierra question doubt
Jacob Sonia
Ranch Hand
Posts: 185
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class Beta { } 4. class Alpha { 5. static Beta b1; 6. Beta b2; 7. } 8. public class Tester { 9. public static void main(String[] args) { 10. Beta b1 = new Beta(); Beta b2 = new Beta(); 11. Alpha a1 = new Alpha(); Alpha a2 = new Alpha(); 12. a1.b1 = b1; 13. a1.b2 = b1; 14. a2.b2 = b2; 15. a1 = null; b1 = null; b2 = null; 16. // do stuff 17. } 18. }
Please help me understand that how is just one object eligible for GC after //dostuff is reached
Rohan Kayan
Ranch Hand
Posts: 123
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Only object pointed by a1 is eligible to GC.
a2.b1 -> b1
a2.b2 ->b2
SCWCD 1.4, SCJP 1.4
Ankit Garg
Sheriff
Posts: 9704
43
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Jacob please
SearchFirst
. This question has been asked many times in the forum. Search for "alpha beta" in the forum, you'll get a lot of good explanations...
SCJP 6 | SCWCD 5 |
Javaranch SCJP FAQ
|
SCWCD Links
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Garbage collection program really confusing me?
How many eligible for gc?
Objects eligible for GC
Error in the SCJP6 Study Guide Mock Exam Question?
Garbage Collection query.
More...