File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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
 
Similar Threads
Java ---== operato
toArray function of ArrayList
How many references and objects ?
adding it all up
Class casting doubt??