1)Which of the following are true about garbage collection?
a] we can set the object references to null to ensure that garbage collection will run perfectly
b] Local variables are candidate for garbage collection when the method returns (finished).
c] To use finalize() you must use a try-catch block or rethrow the error object.
d] The JVM will never run out of memory
e] Garbage collection mechanism cannot be forced
ans is ace but e garbage colection can be forced by calling System.gc()
10) 8.When is the object referenced s1 is available for garbage collection?
1.class gc{
2.public static void main(
String args[]){
3.String s1="hello";
4.String s2=s1;
5.s1=null
6.s1=null
7.}
8.}
ans given is b but jane said that GC is for only heap variable is that
when objecct is created using new ( am i right??)
now if that is right then none shud be the answer but I am just confused with this
GC .here S1 and S2 are in literal pool so gc does not occur
but when method exits then gc takes place or not ps explain me all that
stuff
11)
10.Which of the following are true?
a] Any class that includes a finalize method is not necessary to invoke
super class�s finalize() method
b]
Java uses mark sweep garbage collection algorithm
c] It is guaranteed that only objects with no references will be garbage collected
d] you can suggest when garbage collection will happen
ans given is b, c but for me a also seems to be right
.Which of the following main method in java application is correct?
a] public static main(String args[])
b] static public void main(String []a)
c] private static void main(String args[])
d] public void static main(String args[])
e] public static void main(String)
f] static void main(String args[])
the ans given is b,c,f
but what is the problem with e ??? I think that toois right
13)
now he ans given is c but I think a is ALSO correct
tell me if i am wrong