Which of the following statements related to Garbage Collection are correct. Select all correct answers. A. It is possible for a program to free memory at a given time. B. Garbage Collection feature of Java ensures that the program never runs out of memory. C.It is possible for a program to make an object available for Garbage Collection. D. The finalize method of an object is invoked before garbage collection is performed on the object. Correct Answers: C and D Could anyone explain why B is not included in the answers?
Garbage collection does not ensure a program never runs out of memory. It's still possible gc may never run during a program execution, if badly written - the program will definitely run out of memory.
B. Garbage Collection feature of Java ENSURES(?) that the program never runs out of memory. "Java performs GC for you and eliminates the need to free objects explicitly." pg. 47 "GC is not a Guarnatee that memory will always be available for new objects. You could create objects indefinitely, place them in lists and continue ... GC solves many, but not all memory allocation problems." pg. 48