Overriding Methods

AP Computer Science A· difficulty 4/5

To compare objects by content, you should

  • A

    Use == always

  • B

    Compare hash codes

  • C

    Compare String representations

  • D

    Override the equals method to compare relevant fields

    check_circle

Explanation

Override <code>equals(Object o)</code> for content equality.

Want 10 more like this — adaptive to your weak spots?

Related questions