Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic
Author

Garbage Collection

Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102
How many objects are eligible for garbage collection immediately after line 1? Select one correct answer.



I think there will be 3 objects, two objects stored in array and one array object itself. but the answer is 4.
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
You are right it should be 3 only.


~Sanjeev Singh<br />SCJP 1.5
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Ritu wrote:
(...) Select one correct answer.



Tick "Does not compile" and you are done with this question.

The InterruptedException is neither declared or caught.

Yours,
Bu.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Originally posted by Ritu Kapoor:
How many objects are eligible for garbage collection immediately after line 1? Select one correct answer.



I think there will be 3 objects, two objects stored in array and one array object itself. but the answer is 4.


Remember the object referred to by tGC will also be eligible.
Kay Osade
Greenhorn

Joined: Dec 29, 2006
Posts: 6
Originally posted by Keith Lynn:


Remember the object referred to by tGC will also be eligible.


Why would it be eligible for GC after "line 1"? It still refers to the TechnoGC object that was created in the previous line


And Burkhard is right, this code doesn't compile because InterruptedException is not handled or declared
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Please tell us from which mock exam the question comes.


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

Joined: Feb 07, 2005
Posts: 2367
Originally posted by Kay Osade:


Why would it be eligible for GC after "line 1"? It still refers to the TechnoGC object that was created in the previous line


And Burkhard is right, this code doesn't compile because InterruptedException is not handled or declared


You're right. I was thinking of the end of the main method instead of after the line.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage Collection
 
Similar Threads
garbage collection
New SCJP mock exam
Another garbage collection question
Question 8 Valentin's mock
Garbage Collector Question-1