It is a prog which will destroy object and release memory when they are no longer required. The process of releasing memory occupied by objects, files and database connections are known as Garbage collector.
In java prg has to do nothing to deallocate memory. If prgr wants to do garbage collector manually before an object is destroyed. He has to override the finalize method. The general form is as follows.
protected void finalize()
This method may be called before an object is Garbage collected. The things to be done before that can be coded in this method.
By writing the following lines of code, garbage collected can be subjected to do its job. But, objects are destroyed by garbage collector only when they are not required in memory.