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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:08:36+00:00 2026-05-26T03:08:36+00:00

I have this very long exercise and I came a cross a problem in

  • 0

I have this very long exercise and I came a cross a problem in each sub class.
The problem says and I have no idea what mistake I’ve made while writing.
If you could check the 4 toString methods I would be much apprecaited .

The code is here: http://paste.org/pastebin/view/39488
I know I should past the code here but it is very long and I’m not able to organize it well.

toString() in Shape cannot override toString() in java.lang.Object; attempting to use incompatible return type

toString() in Square cannot override toString() in java.lang.Object; attempting to use incompatible return type
`

toString() in Sphere cannot override toString() in java.lang.Object; attempting to use incompatible return type

toString() in Cube cannot override toString() in java.lang.Object; attempting to use incompatible return type

thanks

  • 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-26T03:08:37+00:00Added an answer on May 26, 2026 at 3:08 am

    You need to change the return type of the function to String and return the text instead of writing it to System.out.

    public String toString() {
        return  "(" + super.getX() + ", " +
        super.getY() +") " + "side: " + super.getDimension1();
    }
    

    EDIT: If you want to have a method that outputs the object directly to System.out in textual form, you’ll need to call it something else than toString(). This is because toString() is a method belonging to java.lang.Object which all Java classes automatically extend.

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

Sidebar

Related Questions

i have a html like this: ......whatever very long html..... <span class=title>hello world!</span> ......whatever
I have this problem for a very long time, but we are about to
I have very long integer sequences that look like this (arbitrary length!): 0000000001110002220033333 Now
I have tried for a very long time now to figure out, why this
I have this very simple C++ class: class Tree { public: Node *head; };
I have this code: String s = A very long string containing + many
Today I have question about Eclipse . I use this IDE very long and
I currently have this very long if statement: if (somesTring != null && !.equals(somestring)
I have this very simple jQuery function: $(.milestone-in-tree).live({ mouseenter: function() { setTimeout( $.ajax({ type:
I have this very simple br2nl function that I use to take a string

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.