• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How many Object classes overridded the equals() method?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many Object classes overridded the equals() method ?
If possible please tell me what are they .
Thank you .
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many. Look out for equals(Object) at http://java.sun.com/j2se/1.4.1/docs/api/index-files/index-5.html
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is only one Object class ...
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean some of the subclasses of Object .
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A book saied as fallows:

The equals() method is a special method contained in the Object class that compares properties between two objects. The properties that the method tests are determined by the type of object being tested. This is in contrast to the == operator, which tests whether two reference variables are the same, as described earlier in the chapter.

The equals() method is typically overridden in a subclass. When this method is not overridden, it is identical to the == operator (it compares two reference variables). For the Java exam you will need to know the behavior of String, Boolean, and Object types.


I just want to know how many these Subclasses are .
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you will have to count them. Is there any particular reason you need to know this?
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I am preparing for the SCJP 1.4 exam.
Do I need to know this?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ths SG:
Well I am preparing for the SCJP 1.4 exam.
Do I need to know this?


No you don't need to know this. You *do* need to know how and where to find out whether or not a class does override the equals() method. And while you're reading the appropriate docs check if that class overrides the hasCode() method also, if not, start revolting and sending in bug reports.
kind regards
ps. My guess is that *nobody* knows from the top of his/her head how many classes override these methods ...
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's good to know for the exam that StringBuffer does not override Object.equals(), but String does.
[ January 28, 2003: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would probably be easier to count the classes that DON'T override the equals method. However, such details aren't necessary for the exam. As stated, you need to know when to use the equals() method and how to find out if a class overrides this method.
[ January 28, 2003: Message edited by: Layne Lund ]
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ilja Preuss,your page is great
and thanks everyone,your suggestions are very helpful.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic