Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection

 
Ritu Kapoor
Ranch Hand
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 381
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right it should be 3 only.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us from which mock exam the question comes.
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic