Extending class Object 02 Flashcards

1
Q

• What is the difference of testing equality using the equals() method or the == operator, and where are they both appropriately used?

A

==: checks if both objects point to same memory location

Equals(): Evaluated to the comparison of values in the objects

They are both used in toString methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

• What is the default behaviour of the equals() method you inherit from class Object?

A

The default equals method compares memory addresses, which means that all objects are different from each other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly