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

  • Home
  • SEARCH
  • 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 8487233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:10:47+00:00 2026-06-10T21:10:47+00:00

this question is like my previous one Given: 3. interface Animal { void makeNoise();

  • 0

this question is like my previous one
Given:

3. interface Animal { void makeNoise(); }
4. class Horse implements Animal {
5.   Long weight = 1200L;
6.   public void makeNoise() { System.out.println("whinny"); }
7.  }
8.  public class Icelandic extends Horse {
9.   public void makeNoise() { System.out.println("vinny"); }
10.  public static void main(String[] args) {
11.    Icelandic i1 = new Icelandic();
12.    Icelandic i2 = new Icelandic();
13.    Icelandic i3 = new Icelandic();
14.    i3 = i1; i1 = i2; i2 = null; i3 = i1;
15.  }
16. }

When line 14 is reached, how many objects are eligible for the garbage collector?

A. 0

B. 1

C. 2

D. 3

E. 4

F. 6

I chose A but the right answer is E, but I don’t know Why?

  • 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-10T21:10:49+00:00Added an answer on June 10, 2026 at 9:10 pm

    Let’s call the three Icelandic objects created in main as A, B and C.

    Initialy

    • i1=A, i2=B and i3=C;

    After i3 = i1

    • i1=A, i2=B and i3=A;

    After i1 = i2

    • i1=B, i2=B and i3=A;

    After i2 = null:

    • i1=B, i2=null and i3=A;

    After i3 = i1

    • i1=B, i2=null and i3=B

    In line 14, there are standing references to only B object of type Icelandic. A and C are lost in the running program.

    Each Icelandic object that is lost gives garbage collector two objects to collect, ie. the Icelandic object itself and the Long object within every Icelandic, which make the total number of garbage collected objects 4.

    Since makeNoise methods are never called, they do not change the outcome.

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

Sidebar

Related Questions

This is a follow-up to my previous question I would like to find a
this question is like this one , except it's for PHP testing via browser.
My question like this: I have a JTable, I put a JProgressBar in one
This one is related to my previous question on the performance of Arrays and
This is similar to a previous question that I asked, with one variation. I
This is a follow-up question to my previous one . Situation: Table 1: +--------------------+--------------------+
This question is linked to my previous one ( posted as an anonymous user
This is a follow up question to my previous one. I want to write
It looks like this question has been asked dozens of times, but none of
Kind of like this question I have many text snippets that I use many,

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.