• 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

ocjp

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
enum Example { ONE, TWO, THREE }
Which statement is true?
A. The expressions (ONE == ONE) and ONE.equals(ONE) are both guaranteed to be
true.
B. The expression (ONE < TWO) is guaranteed to be true and ONE.compareTo(TWO) is
guaranteed to be less than one.
C. The Example values cannot be used in a raw java.util.HashMap; instead, the
programmer must use a java.util.EnumMap.
D. The Example values can be used in a java.util.SortedSet, but the set will NOT be
sorted because enumerated types do NOT implement java.lang.Comparable.

The answer is given as A. Will you please explain why not B?
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dasaradhi Nidumolu wrote:enum Example { ONE, TWO, THREE }
Which statement is true?
A. The expressions (ONE == ONE) and ONE.equals(ONE) are both guaranteed to be
true.
B. The expression (ONE < TWO) is guaranteed to be true and ONE.compareTo(TWO) is
guaranteed to be less than one.
C. The Example values cannot be used in a raw java.util.HashMap; instead, the
programmer must use a java.util.EnumMap.
D. The Example values can be used in a java.util.SortedSet, but the set will NOT be
sorted because enumerated types do NOT implement java.lang.Comparable.

The answer is given as A. Will you please explain why not B?



You might better attract people to your posts if you post your question in the right forum. Take a look here https://coderanch.com/how-to/java/HowToAskQuestionsOnJavaRanch
 
reply
    Bookmark Topic Watch Topic
  • New Topic