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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:12:28+00:00 2026-05-26T02:12:28+00:00

Given Account t, code is meant to enable BankAccount method getBalance to be called

  • 0

Given Account t, code is meant to enable BankAccount method getBalance to be called for the field savingsAccount within an instance of Account. I’ve tried various methods of executing this method.
Mainly variations of the follwing:

Account t = new Account();

t

t.setSavingsAccount(new BankAccount());

BankAccount@xxxxxx

t.savingsAccount.getBalance();

Static Error: No field in account has name “savingsAccount”

how do i rewrite this code so that savingsAccount is considered a field?
is there a better way to execute the method getBalance from within t?

Relevant Code:

    /**
 * A class to track an individuals bank portfolio.
 */
public class Account extends Object{
  private BankAccount savingsAccount = null;              //savings account identification number

 /**
   * A method to set account holder's savings account identification number.
   * @param savings account identification number
   * @return savings account identification number
   */
  public BankAccount setSavingsAccount(BankAccount input){
    savingsAccount = input;
    return savingsAccount;
  }

     /**
      * A method to return account holder's savingsaccount identification number.
      * @return savingsaccount identification number
      */
     public BankAccount getSavingsAccount(){
        return savingsAccount;
     }
    }

/**
 * A class to track the balance and terms of a bank account.
 */
public class BankAccount extends Object{
  private double currentBalance = 0;              //the balance of the account

 /**
  * Returns the balance of the account.
  * @param - void
  * @return the balance of the account
  */
  public double getBalance(){
    return currentBalance;
  }
    }
  • 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-26T02:12:28+00:00Added an answer on May 26, 2026 at 2:12 am

    The correct syntax is

    System.out.println(t.getSavingsAccount().getBalance());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an entity called Account and I have given this entity a class
I'm working with code igniter and for some reason, the url http://mysite.com/account/100 gives me
I need to access a network resource on which only a given Domain Account
I need to check programmatically (in .NET) whether a given user (domain account) is
Given the following code: if ([TWTweetComposeViewController class]) { TWTweetComposeViewController *tweeter = [[TWTweetComposeViewController alloc] init];
I am using this code and settings are provided to check whether mail account
I have some delphi code which, given a list of items, calculates the total
I have a code that is meant to run a check on my database
I was given this source code and asked to compile it: it fails with
I have created some code that emails an html email to a given address.

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.