Free Object-oriented basics lessonsObject-oriented basics · Stage 1 · Protecting state · Step 2
Immutability and value objects
What makes an object immutable, what final does and doesn't do, and why defensive copies matter. About 12 minutes.
Which one is NOT needed to make a class immutable?
- ASynchronising every method
- BMaking the fields final
- CHaving no setters
Show the answer
Synchronising every method. Nothing changes, so there is nothing to synchronise.
4 questions on this idea
Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.
Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve