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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:30:27+00:00 2026-06-15T18:30:27+00:00

If you call this first method, ‘CreateLotsOfAlphas’, what is it supposed to print? I’m

  • 0

If you call this first method, ‘CreateLotsOfAlphas’, what is it supposed to print? I’m just having trouble following the flow of the program. I thought it would print aabbc, but for some reason it actually prints bacbc.

My reasoning is that newA1.y is just the input, a, at first due to the null. a is saved into this.y, so newA2.y is (a + b) with b saved into this.y, then newA3.y is (b + c) to give aabbc.

Am I looking at this wrong or something?

public void CreateLotsOfAlphas() {
    Alpha newA1 = new Alpha(1.0, "a", null); 
    Alpha newA2 = new Alpha(2.0, "b", newA1); 
    Alpha newA3 = new Alpha(3.0, "c", newA2);
    System.out.println(newA1.y + newA2.y + newA3.y);
}

These two methods are in two different classes by the way.

public Alpha(double x, String y, Alpha oldAlpha) { 
    this.x = x;
    this.y = y;
    w = (int) x;
    if (oldAlpha != null) { 
        oldAlpha.y = y + oldAlpha.y;
    } 
}
  • 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-15T18:30:28+00:00Added an answer on June 15, 2026 at 6:30 pm
    Alpha newA1 = new Alpha(1.0, "a", null);
    // oldAlpha == null so we only newA1.y = "a"
    Alpha newA2 = new Alpha(2.0, "b", newA1);
    // oldAlpha is newA1 => newA1.y = "b"+"a"; newA2.y = "b"
    Alpha newA3 = new Alpha(3.0, "c", newA2);
    // oldAlpha is newA2 => newA2.y = "c"+"b", newA3.y = "c"; newA1.y = "ba" (still)
    System.out.println(newA1.y + newA2.y + newA3.y);
    // newA1.y = "ba", newA2.y = "cb", newA3.y = "c"
    

    … clear enough?

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

Sidebar

Related Questions

I have this class file call SMSHelper.cs First I just wanted to know is
The first time i call this method file1 will be nil and file2 will
IN my application i am using this code to Call my First Class Xib.Here
click the button to call this method: private void goRegister(final boolean isUsername) { new
When I call this method: - (void)method:(int)i { while (image[i].center.y <= 100) { image[i].center
First of all, this is not schoolwork - just my curiousity as I for
iReport Version : 3.7.1 I approached this problem in two ways. My first method
In many script language, we have a programming method like this: First, there is
I am trying to call this method to concat two arrays using Google Collections
Some method call this method which has this code: Form frm = new Form();

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.