Identity of object in OOP
Depending on the programming language, some or all objects might have reference semantics. What this means is that when you assign the object to a variable or pass it to a method, it's still the same object, not a copy. This means the object maintains identity independent of the values it holds.

For example, in C#, classes have reference semantics, while structs do not. This means that for a class C and struct S:

C c1 = new C();
c1.Name = "c1";
C c2 = c1;
c2.Name = "c2";
WriteLine(c1.Name); // writes "c2"
WriteLine(c1.Equals(c2)); // writes "True"

S s1 = new S();
s1.Name = "s1";
S s2 = s1;
s2.Name = "s2";
WriteLine(s1.Name); // writes "s1"
WriteLine(s1.Equals(s2)); // writes "False"


As you can see, changing the class instance through one variable affects the other variable too, showing that both refer to the same object. Also, you can see that the two variables are equal. So, classes in C# maintain object identity.

For the struct, each variable is independent: changing one does not affect the other. This means that structs in C# do not have object identity in C#.

Other languages behave differently. For example, Java does not have structs at all, all user-defined types have reference semantics.

As another example, in C++, you can decide to use reference semantics or not on a case-by-case basis, by choosing to use pointers (or references) or not.



Note: Equals() in C# can be overridden. But since C or S do not override it, the default implementation of Equals() mostly behaves the way we want for both.