aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why finalize() can't be defined as private? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why finalize() can Watch "why finalize() can New topic
Author

why finalize() can't be defined as private?

lucy hu
Ranch Hand

Joined: Aug 21, 2000
Posts: 60
who call the finalize() method?
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1441
The finalize method is called by the garbage collector.
The reason that the finalize method can't be private (or have default/package accessibility) is that it is defined as protected in the Object class and Java does not allow you make an overridden method in a derived class less accessible than the method it is overriding. Since private is more restrictive than protected you can't do this.
John


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
lucy hu
Ranch Hand

Joined: Aug 21, 2000
Posts: 60
where does gc come from? is it an object or a class?
asim wagan
Ranch Hand

Joined: Nov 14, 2000
Posts: 62
Hi! GC means the garbage collector. Java has a automatic mechanism for recovering the memory from destroyed objects. The JVM contains a special utility known as Garbage Collector which helps the system to collect the memory.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why finalize() can't be defined as private?
 
Similar Threads
Gc question
finally , finalize()
Garbage Collection
finalize()
Finalization Method