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.