• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Finalize()

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finalize() can be overloaded and can't be overriding.
Correct me if I'm worng
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by suma krishnan:
Finalize() can be overloaded and can't be overriding.
Correct me if I'm worng


Finalizer cant be overloaded but can be overridden
ragu
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Overloading the finalize() method is allowed, but only the method with the original finalize() signature will be called by the garbage collector. Moreover,the new definition cannot contradict the original definition.
As far as overriding is concerned, the finalize() method is declared protected in Object. Therefore, the overriding methods can be only protected or public.
Hope this Helps,
Shyam
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shyamsundar Gururaj:
Overloading the finalize() method [b]is allowed, but only the method with the original finalize() signature will be called by the garbage collector. Moreover,the new definition cannot contradict the original definition.
As far as overriding is concerned, the finalize() method is declared protected in Object. Therefore, the overriding methods can be only protected or public.
Hope this Helps,
Shyam[/B]



If the new overloaded finalizer() method cannot contradict the original finalizer() how can you overload this method?
protected void finalizer() //
protected int finalizer() // Not a overloading
protected void finalizer(5) //Different Signature so overloading
//But it wont compile!!!
So i dont think you can overload a finalizer...
Please correct me if i am wrong
Thankx Shyam
ragu
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ragu,
Actually it can be overloaded. I couldn't believe it at first, but it came from a rather credible source...Mughal..So, I tested out one of the programs in his book...it works!.
Run this code..you'll believe too!

Waiting for your comments
Shyam
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankx shyam that helps
Now my question is Why would somebody overload finalizer in the first place ?
GC only calls the protected void finalizer() signature alone rite?
Ragu
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are absolutely right...No one would ever want to overload the finalizer() method. May be Mughal has mentioned this just as a technical point.
Yes! GC calls the original declaration "protected void finalizer() throws throwable".
Hope this helps
Shyam
[This message has been edited by Shyamsundar Gururaj (edited November 01, 2001).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic