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 a,c,e but garbage colection can be forced by calling System.gc() therefore e can't be true
Bzzt... sorry but thanks for playing. Actually System.gc() is only a suggestion to run garbage collection. The system will decide for itself whether to ignore your suggestion. And this makes sense since garbage collection can be time consuming and someone else may not be thrilled with your running garbage collection and holding up the JVM in the middle of their process.