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 8015943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:24:14+00:00 2026-06-04T20:24:14+00:00

There is a question in SCJP third chapter … see the following code …

  • 0

There is a question in SCJP third chapter …
see the following code …

class Beta{

}

class Alpha extends  Beta{
    static Beta b1;
    Beta b2;
}

class Tester{
    public static void main(String a[]){
        Beta b1 = new Beta();
        Beta b2 = new Beta();

        Alpha a1 = new Alpha();
        Alpha a2 = new Alpha();


        a1.b1 = b1;
        a1.b2 = b1;
        a2.b2 = b2;

        a1 = null;
        b1 = null;
        b2 = null;

        //DO STUFF
        //HOW MANY OBJECTS ARE ELIGIBE FOR GC AT THIS LINE..

    }
}

Q : How are many objects are eligible for GC @ line //DO STUFF

Options :

Option-1> 0
Option-2> 1
Option-3> 2
Option-4> 3
Option-5> 4
Option-6> 5

Book says : The correct ansert is 2 : Only one object is eligible for GC.

Still not able to understand this answer. How only one object can be eligible for GC?

Any Idea ??
Thanx,Gunjan.

  • 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-06-04T20:24:15+00:00Added an answer on June 4, 2026 at 8:24 pm

    here …a1.b1 or a2.b1 is static. so it can not be GCed. But a1 is eligible for GC because its not used. And a2.b1 is pointing to b1. So b1 can not be GCed. We are nulling b2,so it can also be added into GC pipeline. So only two objects a1 and b2 are eligible for GC.

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

Sidebar

Related Questions

This is another of those SCJP questions. The code below prints Alpha:fooBeta:fooBeta:barBeta:bar , and
Newbie question: There are three types of Asp.Net controls : HTML server controls, Web
There is a question here in stackoverflow with the same title but that is
There is a question in my programming languages textbook that is as follows: Write
This question assumes there's a blessed central repository that members of a team clone
Silly question - Is there a way to download the iPhone SDK without Xcode
There's another question: howto make diff look like svn diff? but I want the
There are many question regarding this topic but there is no clear answer. Although
There's a question on this already (here) . But I'm hoping that because I'm
Question Is there a way to define a method only once in C# (in

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.