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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:50:27+00:00 2026-05-28T19:50:27+00:00

I was asked by my text to count the references to an object. Inside

  • 0

I was asked by my text to count the references to an object. Inside the given code was the following:

Honey honeypot = new Honey();

Honey [ ] ha = {honeypot, honeypot, honeypot, honeypot};

Bees b1 = new Bees();

b1.beeHA = ha;

where the constructor for Bees creates the Honey[ ] beeHA array.

Now I thought that beeHA would now hold the reference honeypot in four positions as does array ha and that these would be four separate references plus the four from the ha array making eight references. But the diagram the book gives as an answer say that the beeHA array only points to the ha array not to the object referenced by the honeypot reference variable making only four references. Am I thinking about this correctly?

If array ha were to be garbage collected (subject of the chapter) wouldn’t b1.beeHA[x] still contain the honeypot reference variable?

  • 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-28T19:50:28+00:00Added an answer on May 28, 2026 at 7:50 pm

    ha isn’t an array – it’s a variable. The value of the variable is a reference to the array – as is the value of b1.beeHA. So it doesn’t really make sense to talk about “array ha” being garbage collected. When you write:

    b1.beeHA = ha;
    

    that simply copies the value of ha into b1.beeHA. It’s not copying the array – it’s just copying the reference.

    The code you’ve shown creates one array containing four references to one instance of Honey. There are two references to that array – one in the variable ha and one in the variable b1.beeHA.

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

Sidebar

Related Questions

I were asked to analyze an assembly code, which was generated from following c++
So I recently asked the following questions: Reading A Fixed Format Text File -
Previously I have asked to strip text from a field and convert it to
in this question i asked how to split text by whitespace, now i split
Whenever any question is asked, and a reference text is needed, I never see
I am referring to the following post : Excel distinct count with conditions I
Previously I asked about how I could call separate values from a text file
A client has asked me to add some polish text to their website, not
i asked the question about haw to create a button by a text &
I have been asked to identify all read only text boxes in an Asp.Net

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.