• 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

MindQ

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Is this statement true?Answer is true.
Any class that includes a finalize method should invoke its superclass' finalize method.
I have choosen it as false since every class includes
finalize() of Object class.Only the class which overrides
finalize method must invoke its superclass finalize method.
Correct me where i am wrong.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is very obvious that every class "inherits" the finalize method of the Object class, which does nothing. I think the word includes in the question means implements or overrides.
Calling super.finalize() in the overriding finazlize method is not a must. Compiler does not enforce this rule. However, is a kind of "nice to have" especially when you have more than one class in your hierarchy and some/all of them override the finalize method.
The should have qualifier in the question makes me think the answer is wrong. Because, it is neither enforced nor necessary for classes that inherit directly from the Object class.
Ajith
 
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

Originally posted by Ajith Kallambella:
It is very obvious that every class "inherits" the finalize method of the Object class, which does nothing. I think the word includes in the question means implements or overrides.
Calling super.finalize() in the overriding finazlize method is not a must. Compiler does not enforce this rule. However, is a kind of "nice to have" especially when you have more than one class in your hierarchy and some/all of them override the finalize method.
The should have qualifier in the question makes me think the answer is wrong. Because, it is neither enforced nor necessary for classes that inherit directly from the Object class.
Ajith


Thanks! for the reply.Acct. to Boone, super class finalize()
should be invoked so that the code inherited from super
class is not broken.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I read this some where
"
when extending a class that has a finalize method, you must write a finalize, that executes super.finalize()"
when extending a class that has a finalize method, you must write a finalize, that executes
super.finalize()
So, What is the conclusion? Please help.
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moderators,
Yesterday I had also given this Exam
I answered this question as false
but the exam answer sheet says that it is true.
I differ in view.
Moderators please help.
tvs sundaram
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see why Sun is so picky -- most finalizers never run anyway.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic