Multiple choice

What is the difference between == and equals()?

  1. Both == and equals() check whether two objects belong to the same instance.

  2. == compares characters inside a string object, while equals() check whether two objects belong to the same instance.

  3. Both == and equals() compare characters inside the string object.

  4. == operator checks whether two objects belong to the same instance, while equals() compares characters inside the string object.

  5. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is the correct answer as == operator checks whether two objects belong to the same instance, while equals() compares characters inside the string object.