aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collection dan's question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage collection dan Watch "Garbage collection dan New topic
Author

Garbage collection dan's question

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 477



/*When the processing of line 3 begins, how many objects of type Q that were created at line 1 are eligible for garbage collection?

a. 0
b. 1
c. 9
d. 10
e. Indeterminate.
f. Compile-time error
g. Run-time error
h. None of the above
**/
The given explanation is
If method m2 causes a reference to be saved for each object that is passed in as an argument, then none of the objects are eligible for garbage collection when line 3 begins. Since we don't know what method m2 might be doing, we can not know if the objects are eligible for garbage collection.

But i am thinking,the compiler error will occur a line 2 since we didn't have the method m2(q1);.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You are meant to assume that method m2(Q q) exists but you do not know what it does.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Shiva Mohan:



/*When the processing of line 3 begins, how many objects of type Q that were created at line 1 are eligible for garbage collection?

a. 0
b. 1
c. 9
d. 10
e. Indeterminate.
f. Compile-time error
g. Run-time error
h. None of the above
**/
The given explanation is
If method m2 causes a reference to be saved for each object that is passed in as an argument, then none of the objects are eligible for garbage collection when line 3 begins. Since we don't know what method m2 might be doing, we can not know if the objects are eligible for garbage collection.

But i am thinking,the compiler error will occur a line 2 since we didn't have the method m2(q1);.


Dear Shiva,

This is the most innocent answer I have seen ever in my life.


Well dear, it's not a whole question given in the paper, you must assume that there is a method m2();. And if you are looking at compile error then why didn't you point out the main method missing and no class definations block is there.

Well, I think now you got the point, you have to assume about the method m2(Q q1);.


The Best way to predict your future is to create it - Every great individual common man
Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 477
Ok�......

If method m2 causes a reference to be saved for each object that is passed in as an argument, then none of the objects are eligible for garbage collection when line 3 begins.



If method m2 causes a reference to be saved for each object that is passed in as an argument, then none of the objects are eligible for garbage collection when line 3 begins

Is true.Can anyone please explain the above sentence for me.
[ September 29, 2006: Message edited by: Shiva Mohan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage collection dan's question