Sethuram,
Tried to putdown comments to some of your questions.
1. We don't HAVE CONTROL on garbage collection. [yes/no]
Comment: We have some control on GC. You can request JVM to do GC by using one of the System.gc() or Runtime.getRuntime.gc() methods. So the Answer is No.
2. It is upto JVM to garbage collect on "heap of objects". [y/n]
Comment: Yes..It is upto the JVM to do GC. But if you think you have enough time (before user responds in your
applet etc), you can make a request to JVM to carry on GC as explained above.
3. Box b = new box(2,3);
b = new box( 3, 4);
line 1 object is elgible for gc. [y/n]
Comment: Yes.
4. Before gc , JVM is will EXCUTE finalize() method.[y/n]
Comment: Yes.
5. If we don't code finalize(), will JVM execute the default finalize() method in Object class.
Comment: No..JVM will try to execute the inherited finalize() in the super class, if any.
6. If we override finalize(), will JVM exceute ONLY overriden finalize() method.
Comment: Yes..So whenever you override the finalize method, it is advised to invoke finalize() of the super class.
7. what happens if there is an exception in finalize() method?
Comment: The exceptions raised in finalize() are ignored. Meaning the JVM will not try search the stack to find the exception handler.
9. Box b = new Box(3,4);
b = null
object in line 1 will be eligible for gc?
Comment: Yes� Object in line 1 is eligible for GC. Please correct me if I am wrong. That leaves question 8 unanswered. Can some one answer this?
Regards,
Kondal.