my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collection query 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 query" Watch "Garbage collection query" New topic
Author

Garbage collection query

vidhya suvarna
Ranch Hand

Joined: Aug 28, 2008
Posts: 148
Source: http://www.akgupta.com/Java/mock_exam.htm

Which of the foll are true?
1) Because of Garbage collection java program doesnot run out of memory
2) Garbage collection use mark and sweep algorithm
3) Garbage collection is implementation dependent
4) Garbage collection is platform independent
5) System.gc forces Garbage collection

according to me option 4 appear to be one to the correct answer. Option 5 is wrong for sure.

Can anybody verify and tell me know the exact right answer for this?

Thanks,
Vidhya


SCJP 1.4 - 88%<br />SCWCD 1.5 - Preparing
Marco Piva
Greenhorn

Joined: Aug 24, 2007
Posts: 12
IMHO the correct answer is:

3) Garbage collection is implementation dependent


SCJP 5.0
vidhya suvarna
Ranch Hand

Joined: Aug 28, 2008
Posts: 148
can someone confirm the answer
Hrishikesh Maluskar
Ranch Hand

Joined: Jun 19, 2008
Posts: 115
1) Because of Garbage collection java program doesnot run out of memory
False -> Since we cannot control garbage collection , it is completely controlled by the JVM. Only thing assured is that whenever we are short of memory the Garbage collector will try its best to utilize the memory effictively , but not guranteed to run.

2) Garbage collection use mark and sweep algorithm
False -> Java Specification does not gurantee any particular Implementation

3) Garbage collection is implementation dependent
True -> JVM designers are free to design their own implementation for garbage collection.They can also not implement it at all.

4) Garbage collection is platform independent
True -> JAVA language is platform independent , hence anything associated with it is platform independent.

5) System.gc forces Garbage collection
False -> Nothing in this world can force garbage collection.System.gc is just a request to the JVM.


SCJP 1.5
www.licexpadvice.com
Paul Somnath
Ranch Hand

Joined: May 19, 2008
Posts: 177
I didn't understand option Four.
Does that mean that garbage collection happens in every underlying OS?
If that is the case, then yes its true.
But Garbage collection algorithms are different for different platforms.


Preparing for SCJP 6.0
Pranav Bhatt
Ranch Hand

Joined: Mar 20, 2006
Posts: 284
Out of all i doubt about option 3 to be True i.e
3)
by Hrishikesh Maluskar..
Garbage collection is implementation dependent
True -> JVM designers are free to design their own implementation for garbage collection.They can also not implement it at all.


You can implement GC on your code but even if you implement you are not sure that GC will take place. Moreover even if you don't, GC may run too. So it would be independent of implementation.
sweety sinha
Ranch Hand

Joined: Jul 07, 2008
Posts: 76
3) Garbage collection is implementation dependent
True -> JVM designers are free to design their own implementation for garbage collection.They can also not implement it at all.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You can implement GC on your code but even if you implement you are not sure that GC will take place. Moreover even if you don't, GC may run too. So it would be independent of implementation.
...............................................................
there seems to be two different answers regarding option 3.
so which is the most appropriate answer that is whether it is implementation dependent or not. please confirm
kaushik vira
Ranch Hand

Joined: Feb 01, 2007
Posts: 102
Out of all option 3 is True. GC is not platform dependent but you can choose you GC implementation by passing some option in start up jvm instruction.


kaushik Vira
-------------------------------------
SCJP, Preparing SCWCD..
 
jQuery in Action, 2nd edition
 
subject: Garbage collection query