Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection

 
B pandoo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Determine which of following statements are true(multiple options)

1)Garbage collection is performed by a low priority daemon thread.
2)garbage collection always uses mark and sweep algorithm
3)The finalize() method is invoked for the objects in the order in which they were created.
4)The finalize method is typically used to free up the resouces other than memory.
5)objects that are created and accessed locally within the method ,are eligible for garbage collection when the method returns.

please tell me which statements are true.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which do you think are true? what has your research found, and what doesn't make sense?
 
B pandoo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the true statements are 3,4,5.
I want to clarify whether my answers are correct.
and then i know that statement 2 is wrong.May i know whether statement 1 is correct or wrong?
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess the first one.
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can 3,4,5 be the correct options??
 
B pandoo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i believe so.I am not sure.so only i am asking guidance from the group
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

There are many other algorithms apart from mark and sweep.
The finalize method does not run on objects created in any order.

The fourth one can be true.

Tha last one is definitely not true.
 
B pandoo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.what about option 1
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's great to discuss mock questions on this forum, but the authors of the questions really appreciate it when you credit them! For instance you can say:

"This question is from Dan Chisolm..."

Thanks!
 
Abdul Rehman
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option 1 is true. Garbage collection is indeed performed by a daemon thread.
 
Rick Reumann
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the actual answer? ( 1 and 4 ?)
 
Krzysztof Koziol
Ranch Hand
Posts: 133
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my opinion is 1,4 and 5.

Regards
 
Dan Polak
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
5 is not true Krzystof because we can create and start thread in that method
 
krishnareddy mudiyala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
This is my first post in the forum.
i think 1 and 4 are TRUE (99.99%).

------
Thanks to Head First Series
 
venkatesh pendharkar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes only 1 & 4 are correct
 
venkatesh pendharkar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes only 1 & 4 are correct
 
Abdul Rehman
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is 2 correct or not?
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure the original question was quoted exactly, and especially for GC questions the EXACT wording is important - if that IS the exact wording then the question is suspect. Given all that, I don't think you guys have the correct answer yet - although I would say that before spending too much more time on this one, the thread originator should verify that the EXACT wording has been used.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Bert implies, so much time has been wasted on this simple issue. So, please, always give the exact origin or source of the mock questions.
 
krishnareddy mudiyala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes questions is not clear but given that

1 true
2 cannot guarantee
3 false
4 true
5 true
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think 1 isn't always true. I would guess that's it's usually true, but I think you could create a Sun certified JVM that used a different technique.

Again - the wording on these mock GC questions has to be absolutely precise or the question is rendered meaningless - and this question falls squarely into the "imprecise" category. :roll:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic