2. When does Java know an object is no longer needed? And what happens to
an unneeded object's storage?
A. The programmer tells Java when an object is no longer needed by calling
dispose() on it; the object's memory is released back to the memory pool.
B. If there are no references to the object, Java knows the object is no longer
needed and automatically returns its memory to the memory pool.
C. If there are no references to the object, Java marks it as no longer needed; the
memory stays in use until the programmer explicitly returns it to the memory
pool.
D. Objects, once constructed, stay active until the program terminates, so though
the programmer may know an object is it no longer needed, Java does not
know this; objects' memory is returned to the memory pool when the
program terminates.
E. Objects, once constructed, stay active until the method in which they were
constructed terminates, so though the programmer may know an object is no
longer needed, Java does not know this; objects' memory is returned to the
memory pool when the method terminates.