Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

q on threads

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Options are:

1 0
2 1
3 2
4 3
5 4

I answered three, but the correct ans is zero. yy?

plz explain. Wht i understand is when u pass objects, u r passing a reference to the original object. so, when u pass x to the method findOut, this method sets x = null and hence, it becomes eligible for garbage collection. Am i wrong or is there any other way to look at this?



(code tags added - pseudo english not corrected)
[ November 10, 2004: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like, what was the question? How many threads?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When x is passed to the method findOut(Integer y) the value contained in x is copied to y. The value contained in x is not the object itself but a value which can be used to locate the object.

Since x and y will contain same values they can both locate and access the object. We are only setting y to null but x still contains the value...or in other words a reference to the Integer object and hence it cannot be garbage collected.
[ November 10, 2004: Message edited by: Atul Chandran ]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JayaSiji Gopal,
In this post u haven't mention any questions. It is totally irritating.
 
Liar, liar, pants on fire! refreshing plug:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic