• 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

Question regarding javacertificate.com study question

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some concerns regarding a question I saw at javacertificate.com. Here's the question.

I believe the answer is (4), since the class Computer is supposed to implement the Comparable interface, but neither implements " int compare(Object, Object) " nor is declared abstract. But according to javacertificate.com, the answer is (2). What am I missing, or is javacertificate.com wrong? Thanks.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Comaparable interface has one method:
public int compareTo(Object o)
This is indeed implemented. I do not believe, however, that it is ever invoked as it seems to be used by sort methods of the Collections and Array classes.
Three objects are added to the HashSet on the basis of them not being the same (not having the same object references) according to the equals method inherited from Object.
 
David Willis
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I see what I did. I got the Comparable and Comparator interfaces mixed up.
Thanks.
 
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic