• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Garbage collection query

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMHO the correct answer is:

3) Garbage collection is implementation dependent
 
vidhya suvarna
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can someone confirm the answer
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic