• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

finalize() chaining?

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
code
--------------------
class a
{
protected void finalize()throws Throwable
{
s.o.p("a: finalize()");
}
}

class b extends a
{
protected void finalize() throws Throwable
{
s.o.p("b : finalize");
}
}
--------------------

Whats the way to call finalize Top to Bottom or Bottom to Top.

if the object of class "b" is being garbage collected, whose finalize would be called first "a"(parent) or "b"(child)?

Thanks
Chetan Dhewal
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
overridden finalizers are NOT implicitly chained if u want that to happen you have to write code super.finalize().

In your code if b if garbage collected then ....only b's finalize() method exceutes
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesnt the overriden method ned tohave access modifier more than the supeclass method???

Thanks
Balaji.S
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic