Senior Java Software Developer Interview Questions — part 3

Daniel Zielinski
5 min readApr 5, 2023

Part 1, Part 2, Part 4

1. Describe what are value objects?

Value objects are objects that represent a value or concept rather than an entity. They are often used to encapsulate simple data types such as integers, strings, and booleans into an object. Value objects are immutable, meaning their state cannot be changed after they are created, which makes them useful for passing values between objects without worrying about unintended modifications.

In contrast to entity objects, which represent unique objects with identity, value objects are defined by their attributes and can be considered equal if their attribute values are the same. This means that two instances of a value object with the same attribute values are considered equal, even if they are different objects.

Value objects are often used in domain-driven design to represent concepts such as dates, times, currency, and measurements. They can also be used in functional programming to represent function arguments and return values.

Value objects are typically implemented as immutable classes with final fields and no public setters, ensuring that their state cannot be changed once they are created. They usually override the equals() and hashCode() methods to…

--

--