This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic
Author

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?

Options

Select 1 correct option.

1.obj.destroy();
2.System.getRuntim().gc();
3.obj = null;
4.obj.finalize()
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
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage Collection