Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


For object reference comparison, which operators are used?

  1. == and !=

  2. equals() and !equals()

  3. hashCode() and !hashCode()

  4. == and ===

The correct answer is: == and !=

Certain operators like the == and != do not compare the contents of objects, but rather the memory reference/address. This means these operators simply check if the objects being compared are the same object, not if they have the same content. The equals() and !equals() methods are used for content comparison, but these are not operators. The hashCode() and !hashCode() methods simply return unique hash codes for objects, they do not compare objects. The === operator is not a valid Java operator. Therefore, the correct answer is A as it correctly identifies the operators used for object reference comparison.