Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6203367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:54:12+00:00 2026-05-24T04:54:12+00:00

Assume that I have the following class class A { //some attributes @override protected

  • 0

Assume that I have the following class

   class A {
           //some attributes 

        @override
         protected void finalize() throws Throwable {
              //do something

       }
  }


   class B extends A {

           @override
         protected void finalize() throws Throwable {
             //DONT call super.finalize() 
             //do something

       }
     }

What will happen in this scenario ? Will calling class A’ finalize method will be called by garbage collector at some point?

What is the different between calling it and not calling A’s finalize method in the child class’ finalize method if it’s anyway going to be called by garbage collector ?

In what scenario, it is ok NOT to call its parent’s finalize method in the child class? Any example of such a scenario ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:54:13+00:00Added an answer on May 24, 2026 at 4:54 am

    First off, explicitly calling a finalize() method is just like calling any other Java method. It is never OK to not call the parent’s finalize() method if your specific class is overriding the finalize() method. Of course, if you implement the finalizer guardian pattern, you don’t need to explicitly call the parent finalizer in your subclass.

    BTW, don’t rely on finalize() methods for cleaning up resources which can be cleared explicitly (like closing file handles etc.) since finalizers are non-deterministic. Also, take a look at the presentation by Bob Lee for using Phantom references in place of finalizers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that we have the following code: class Program { static volatile bool flag1;
Let's assume that I have following models: class ScoutBook(models.Model): troop = models.ForeignKey('Dictionary', limit_choices_to={'type' :
Assume that I have a .NET Workflow Foundation (WF) SequenceActivity class with the following
So I have a class that looks something like the following: public class MyClass
I have to assume that the following method doesn't leak memory: public final void
Assume that I have three class; UserAccount, UserGroup and Role. UserGroup and Role are
Assume I have the following two classes: public class User : Entity { public
I have to following HTML: <ul class=ulclass> <li class=liclass> ...some more nesting <a href=somelink>somelink</a>
Assume that I have this piece of code: @interface Foo : NSObject { Bar
Assume that we have multiple arrays of integers. You can consider each array as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.