• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

finalize() question

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


Which of the following statements are true about the finalize method?

1- Is called only once in the life of an object
2- Implicitly calls super.finalize()
3- May throw exceptions which are ignored by the Garbage Collector.



I say 1 and 3.

If you have to choose one out of three, what would you choose?

Source: Whizlabs

Thanks,
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
chandra both 1 and 3 are equally true.
 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think 3 is true if only one option is to be chosen becuase garbage collection might never happen during lifetime of a object, the application might end and JVM might shutdown before garbage collection happens to retrieve memory.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sharan you thought in my way.


But reasoning of Megha is correct, we should agree with her.




Thanks,
[ May 02, 2007: Message edited by: Chandra Bhatt ]
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm.. interesting take.


Which of the following statements are true about the finalize method?

1- Is called only once in the life of an object



Also they haven't mentioned by whom,

finalize method is called only once in the life of an object by the garbage collector

It is a protected method and no one is stopping me from calling it as a method. [ ]
[ May 03, 2007: Message edited by: swarna dasa ]
 
I do some of my very best work in water. Like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic