Intermediate
Java
Q42 / 100
What is the difference between == and equals() when comparing Strings?
Correct! Well done.
Incorrect.
The correct answer is B) == checks reference equality; equals() checks content equality
B
Correct Answer
== checks reference equality; equals() checks content equality
Explanation
== compares memory addresses (references) while equals() compares the actual character sequences. Two distinct String objects with the same content are == false but equals() true.
Progress
42/100