• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

I'd like to would like to know the reason behind this statement.

Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a statement regarding throwable object in finalize() method. I'd like to knwo the reason behind this statement. Could anyone explain me?Thank you.

The finalize() method in Object can throw any Throwable object. Overriding methods can limit the range of throwables to unchecked exceptions. Further overridden definitions of this method in subclasses will not be able to throw checked exceptions.

Posts: 979
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

To start with, the statement is generally applicable,
it's about the rules of overriding.

The exception classes structure is as follows:

Unless they are subclasses of RuntimeException, any subclass
of Exception is a checked exception.

Suppose a method, here finalize(), declares to throw a Throwable
exception. A second, overriding method might declare to throw a
subclass of RuntimeException, thereby limiting the range of
exceptions that can be thrown by the method to the unchecked
exceptions. If you don't declare to throw a checked exception
the method can never throw it to a calling method, the compiler
will take care of checking this before you even start, from
there the name checked exception.

If a method overrides the method mentioned above, one of the
rules of overriding becomes more evident: when overriding you
cannot throw more checked exceptions than the overridden method
can. Thus, in this case, you are limited to the range of unchecked


Gian Franco Casula
[ September 19, 2004: Message edited by: Gian Franco Casula ]
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic