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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:43:24+00:00 2026-06-17T13:43:24+00:00

Object is on the top of Java classes. String is a subclass of Object.

  • 0

Object is on the top of Java classes.
String is a subclass of Object.

So, what was first – Object or String?

The prompt answer is – Object.

But the interesting thing is that Object already has a method toString(), and thus “knows” about String. So, when Object is constructed, the String has to already exist. On the other hand, String is a subclass of Object, and when String is constructed Object has to already exist. We fall into a never ending definition cycle (and some technical problem, too). Such approach at least violates the idea of a single root class.

The concern may look like rather theoretical, than practical.

But the thing is that I see a similar approach in other frameworks.
I think at least to some extent it was inspired by the way core Java classes were design.

What do you think – are circular dependencies between Java classes in general (and particular in case of Object/String) inevitable?
Shouldn’t they be avoided at any cost?
Or can they be accepted sometimes (with discretion and caution) as the result of a reasonable compromise? If, so – what are the criteria?

  • 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-17T13:43:26+00:00Added an answer on June 17, 2026 at 1:43 pm

    Java hasn’t a one-pass compiler but a multi-pass compiler.

    This means that all classes that are compiled together are really at the declaration level. Even if they have circular dependencies these are solved in a first step so the fact that Object class provides a toString method does not conceptually mean anything in relation to having or less a root class.

    Since we’re talking about theoretical issues the relation between a class declaration and and which is the real root class is resolved easily:

    Object is the root class just because String inherits from it.

    The String toString() is nothing more that a signature that is useful to the compiler to grant type safety, Object doesn’t require a String object, it doesn’t even need to know what a String is.

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

Sidebar

Related Questions

In Java, all classes are extending Object class implicitly , on top of that
I have an application that calls getStackTrace() on a java.lang.management.ThreadInfo object, but the StackTraceElement
Standard Java does not offer an object implementing the Queue interface on top of
I know that top-level functions are members of the window object, and it's consistent
Object slicing is some thing that object looses some of its attributes or functions
Java's Object.wait() warns against spurious wakeups but C#'s Monitor.wait() doesn't seem to mention it
My Java classes organization has gotten a little messy so I'm going over something
I understand that the class Object is at the top of the class hiearchy
There is a very particular edge case in cross-domain policies regarding the window.top.Location object...
I know two 3D-points in a line (top and bottom of an unsymmetrical object),

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.