• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAVA OCA Puzzle (K&B7, Chapter 3, Question 11)

 
Jikun Zha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


After running, a1, b1, a2, b2 which object will be removed by gc?
 
Puspender Tanwar
Ranch Hand
Posts: 397
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Jikun Zha, First of all a warm welcome to CodeRanch
from next time please put your code in a code syntax provided above (when you ask question), there is a button named code .
coming to your question, i think two objects are eligible for GC .
I have seen this code somewhere, may be in enthuware mocks . Please also do provide the name of the source you have found the code .
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jikun Zha,

First of all, a warm welcome to CodeRanch!

Jikun Zha wrote:After running, a1, b1, a2, b2 which object will be removed by gc?

This question (chapter 3, question 11) from K&B7 has already confused many ranchers and therefore many topics exist already about this question. You'll find these topics here, here and here. These topics are definitely worth reading as they have great explanations, code snippets and even some drawings. I'm pretty sure all your doubts will be cleared if you carefully have read these topics. If you still would have some doubts and/or questions, don't hesitate to let us know by simply hitting the "Post Reply" button

Hope it helps!
Kind regards,
Roel

PS1. Always use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers. Jeanne already added the code tags for you. See how much easier the code is to read?
PS2. When you post a code snippet or a quote from a study guide or any other resource, you should always QuoteYourSources.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic