answersLogoWhite

0

What do you mean by finalizer method?

Updated: 8/19/2019
User Avatar

Wiki User

13y ago

Best Answer

In C++ you have object constructors and object destructors. Both are called by the developer.

In Java and C# you have constructors and finalizer methods, so Java and C# both have support for finalizer methods (also known simply as finalizer).

So the finalizer methods are similar to the destructors of C++ with a very important twist, the finalizer method is called by the garbage collector when an object is freed and not by the programmer (like the destructors in C++).

Both finalizers in Java, C# and destructors in C++ can be used to free resources such as sockets or file handles that the method is using.

However, because the finalizer methods are called by the garbage collector the programmer has no control of when the finalizer method will be called. As such it is NOT A GOOD IDEA to use finalizer methods. One can write the methods of an object in such a way as to clean up after themselves.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What do you mean by finalizer method?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

When did Finalizer - video game - happen?

Finalizer - video game - happened in 1985.


When was Finalizer - video game - created?

Finalizer - video game - was created in 1985.


What is finalize and finalize-and finalized?

The idea of the finalizer method was to do clean up stuff, like releasing IO resource to a database or a file, as this method is called just before the garbage collector removes the object from memory. The problem is that you cannot influence when or IF the garbage collector will clean up your object, so you have no guarantee that the finalize method is ever called. There are even more issues with the finalizer method, the shorty story is to just avoid it and use a "try finally" block instead - closing the resources in the finally block will guarantee that the resources will be released. If you want to know more, I have a free video both about the finalizer method as well as exception handling on my blog (just Google for "Marcus Biel Clean Code Course")


What is finalizer in java?

Finalizes variables so they can't be changed after being initialized.


Why constructor and destructor cannot be made static?

The term "destructor" made me believe this question is related to .Net languages. A destructor is to destroy an instance of object. If it is available at static/class level, what is it going to destroy? The entire class, so the class no longer available? Thus, semantically, destructor should be an instance method. Constructor is on the opposite end of the life cycle of an instance. However, in .NET, a static constructor is allowed. Personally, I call this static constructor as a class initialization method. This method will be invoked by the .net framework only once when the class is loaded into the application domain. With the similar concept, there should be a "finalizer" of the class when the class is unloaded out of the application domain. But wait, does a class ever go out of the application domain once it's loaded? Yes, only at the termination of the application! Currently a class cannot be unloaded explicitly in codes and thus no point to have a static finalizer.


What does pay method mean?

what does pay method means


What does method mean in science?

The method is how you will carry out an experiment.


What does f mean in scientific method mean?

No


What does undoing method mean?

not do


What is the formula of finding mean using direct method?

formula for finding mean through direct mean method: sigma fi xi /sigma fi


What do you mean by nesting method?

jhgjin


What do you mean by WDV method?

wdv method means written down value method. while it is used in depreciation evaluation.