• 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

Garbage collector in java

 
Ranch Hand
Posts: 49
Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please QuoteYourSources.

... and also ... what do you think the answer is?

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

Henry Wong wrote:Please QuoteYourSources.

... and also ... what do you think the answer is?

Henry




I want to try the question out..........
First of all, execution of a java program starts from the main method, beginning from the main method an instance of the TestClass is created '//3'
The method getMyClassObject is called on the instance variable tc, where the result is assigned to x of type MyClass, going into the getMyClassObject
that is where MyClass object is actually created with a reference type mc which returns the object reference at the end of the method.
Meaning that on line  '//4' the x variable of type MyClass holds the returned reference from the method getMyClassObject.
On '//6' the x variable of type MyClass is now pointing to a newly created object.
So it is actually after on line '//7', where the object with the reference x will be eligible for garbage collection.

These are my thoughts, just wanted to try out the question.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic