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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:17:22+00:00 2026-06-17T20:17:22+00:00

In many object oriented languages such as Java, the .NET family, Python, Ruby, and

  • 0

In many object oriented languages such as Java, the .NET family, Python, Ruby, and I’m sure a host of others, the root object class from which all other classes inherit defines an equality checking method. However, in my experience, many of the classes I create really don’t need an equality check or I (or co-workers) don’t bother overriding the default method because we don’t intend to use it. In the latter case, the default equality method doesn’t represent equality very well for that class. So why do so many languages provide this method as part of the definition of the root object class when it seems like many classes should not? Why not leave off the equality method and force users to define it when they need it?

  • 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-17T20:17:23+00:00Added an answer on June 17, 2026 at 8:17 pm

    For any objects references X and Y, regardless of their types, it is possible to meaningfully ask and answer the question “Is the object referred to by X equivalent to the one referred to by Y“. If X represents a Porche 911 automobile and Y represents a cast-iron park bench, the answer would simply be “no”. To be sure, if one knew that X was a car and Y a bench, one likely wouldn’t bother asking, but suppose X, Y, or both, were “things that one may be asked to paint”. One might not know whether or not X and Y are of the same type, and the objects are not equivalent, one may not care. Having a universal means of asking equivalence saves code the trouble of having to worry about objects’ exact type.

    The reason to have all objects implement Equals as a virtual method is that it’s the easiest mechanism by which objects can supply a definition of equivalence that is broader than referential equality. It is often useful to have immutable objects report themselves as equivalent to other objects which have the same immutable state [e.g. having two strings, both holding the six characters “GEORGE”, reported each other as equivalent] Having all objects implement Equals as a virtual method, and having mutable objects’ implementation simply report referential equality, is generally easier than having an Equals function which can only be used on immutable objects. After all, it’s not hard for an mutable object to simply report itself as unequal to anything other than itself.

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

Sidebar

Related Questions

In object oriented languages I use class variables to track how many instances are
I am planning to write an object-oriented shell (based on Python). I have many
Programming languages like C# or Java feature static methods, despite being heavily object oriented.
I'm implementing a standard as an object oriented library in Java. Standard includes many
Nowadays there are so many programming languages out there: functional, object oriented, dynamically or
Many PHP systems will implement object types (such as Models) that allow a client
Many embedded engineers use c++, but some argue it's bad because it's object oriented?
Wikipedia used to say* about duck-typing : In computer programming with object-oriented programming languages,
In the Ruby Programming Language , Chapter 6 (second paragraph) they state: Many languages
Find many authors interchangably use the term Type and Class. Certain textbooks covering 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.