File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic

Garbage Collection

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Consider the following code snippet:

void mymethod()
Object obj = new Object();
// 1 insert code here

What can be inserted at // 1, which will destroy the object refered to by obj?


Select 1 correct option.

3.obj = null;
5.None of these.

Answer given is: option 5

Question: Why option 3 is not correct

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
janki tangeda
Ranch Hand

Joined: Jun 07, 2005
Posts: 54
We cannot force an object to be destroyed or garbage collected.
obj = null;
//makes the object eligible for garbage collection but doesn't destroy it.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
I agree. Here's the link:
subject: Garbage Collection
jQuery in Action, 3rd edition