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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:40:36+00:00 2026-06-14T23:40:36+00:00

I have a project and I am facing a problem I had before again.

  • 0

I have a project and I am facing a problem I had before again.

We have this Tester file given. Should not edit it.
I want you to focus on this line:

System.out.println(bb) ;

It prints the object right?

import java.util.Arrays ;
/**
   Presents some problems to the BillBoard class.
 */
public class BillboardTester
{
    public static void main(String[] args) 
    {
    int[] profits = new int[]{1, 2, 3, 1, 6, 10} ;
    int k = 2 ;
    System.out.println("Profits: " + 
               Arrays.toString(profits) + "   k = " + k)  ;
    Billboard bb = new Billboard(profits, k) ;
    System.out.println("Maximum Profit = " + bb.maximumProfit()) ;
    System.out.println(bb) ;

    k = 3 ;
    profits = new int[]{7, 4, 5, 6, 1, 7, 8, 9, 2, 5} ;
    System.out.println("Profits: " + 
               Arrays.toString(profits) + "   k = " + k)  ;
    bb = new Billboard(profits, k) ;
    System.out.println("Maximum Profit = " + bb.maximumProfit()) ;
    System.out.println(bb) ;
    }
}

Then by printing the object, he expects this result:

Billboards removed (profit): 3(1) 0(1) => profit loss of 2
total value of billboards = 23
remaining maximum profit = 21

I don’t know what method do I have to create in the actual Billboard class, so I can get this printed out. Do you have any suggestions? I want to know the logic behind this, rather than a solution to that particular problem.

  • 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-14T23:40:38+00:00Added an answer on June 14, 2026 at 11:40 pm

    Override toString method.

    Whenever you print any instance of your class, the toString method is called. If you don’t override it, Object's class toString will be used, which returns a representation having type@someNumber form.

    To print your own representation, just override it, and then your implementation of toString will be invoked.

    @Override
    public String toString() {
        return this.getProfit();
    }
    

    You can change your returned string accordingly. I don’t know what your k is, but you can also include that in your returned string.

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

Sidebar

Related Questions

I am facing this problem that buttons in android are not clickable when given
I'm facing a problem I have never had before. The other day when I
I'm working on the project. Currently I'm facing a problem, I have 3 UITableView's
I have project I want to upgrade to .Net4 and it use BackgroundCopyManager.dll. Anyone
folks! I have project in cc.net and this project nay start by 3 ways
I'm here facing a problem with a Java web project. The project I'm working
I am facing a problem in my application. I have some section in application
it's me again. And today, I'm facing kind of a weird problem. Either I
I'm facing the following problem and don't have an answer to it: We have
Im facing a problem where i want to schedule a certain java application to

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.