This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

MindQ

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
I don't see why Sun is so picky -- most finalizers never run anyway.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic