What is Finalizer Methods



We have seen that a constructor method is used to initialize an object when it is declared. This process is known as Initialization. Similarly, Java supports aa concept called finalization, which is just opposite to initialization.

We know that Java run-time is an automatic garbage collecting system. It automatically frees up the memory resources used by the objects. But objects may hold other non-object resources such as file descriptors or window system fonts. The garbage collector cannot free these resources. In order to free these resources we must use a finalizer method. This is similar to destructor in C++.

The finalizer method is simply finalize() and can be added to aany class. Java calls that method whenever it is about to reclaim the space for that object. The finalize method should explicitly define the tasks to be performed.

Random Posts

  • What u mean by Web Application
  • Difference between executeUpdate and executeQuery Methods
  • Difference between Print() and Println() Methods in Java
  • What is Abstract Class?Explan
  • Java Multi-Thread Questions

Post a Comment