D

Dhruva Jagannath • 660 Points
Invincible

Q. Can enum constants be compared using '=='?

  • (A) No, '==' only works with primitives
  • (B) Yes, enum constants are singleton and can be compared with '=='
  • (C) Only if you override equals()
  • (D) Only in Java 11 and above
  • Correct Answer - Option(B)
  • Views: 16
  • Filed under category Java
  • Hashtags: Java Enums

Explanation by: Dhruva Jagannath
Enum constants are singleton and can be safely compared using '=='.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.