-3
  1. Why do we need to override the method public boolean equals(Object ob) in any class?

  2. Is public boolean equals(Object ob) is same as public boolean equals(Circle ob)?

HACK
  • 1
  • 1
  • 3
    1. Well, you don't *have* to. 2. No, it's an *overload*. – MC Emperor Feb 15 '20 at 10:23
  • @Stefan: no, the default does not include "all attributes". The default implementation of equals and hashCode of `Object` perform an identity/reference comparison: two objects are only equal, if they point to the same location in memory. So `a = new Object(); b = new Object(); a != b;` (they are not equal), only `a = new Object(); b = a; a == b;` (same reference) – knittl Feb 15 '20 at 18:43
  • Thank you knittl, I deleted the wrong comment – Stefan Feb 15 '20 at 18:45

1 Answers1

0
  1. You don't have to.
  2. No, it is not.
knittl
  • 246,190
  • 53
  • 318
  • 364