Which of the staements is true??
1 Garbage collection is platform dependent
2 You can suggest when garbage collection will run but cannot be certain when it will take
place
3 A reference to a primitive variable is eligable for garbage collection when it is set to null
4 The automatic garbage collection of the JVM prevents programs from ever running out
of memory
Ans in comments
QUESTION OF THE DAY
Posted by gautam at Saturday, August 04, 2007
Subscribe to:
Post Comments (Atom)
4 comments:
The Correct Answer is
1) Garbage collection is platform dependent
2) You can suggest when garbage collection will run but cannot be certain when it will take place
Option 3 should be suspicious as it refers to a "reference to a primitive", the term reference is used for objects in Java not primitives. If you create enough references to objects that do not become eligable for garbage collection you will eventually run out of memory.
the correct answer must be
second and fourth
The fourth is not always correct
Because garbage collector collects in a way which is not controlled by the programmer but by the cpu.
and and there can be some situations where there is memory overflow.
only thing we can do is to prevent memory overflow and this we can do by referencing the object to null
for eg
string a=null;
is eligible for garbage collection
2 True.
(You can suggest when garbage collection will run but cannot be certain when it will take
place).
But one, the term 'platform' misleading. Actually it is JVM implementation dependent.
Post a Comment