← Quiz: Immutability and Value Objects: all 10 questions
Quiz: Immutability and Value Objects · Question 7 of 10
Why are immutable objects automatically thread-safe?
Why are immutable objects automatically thread-safe?
- A.Java runs them on a single thread
- B.They use synchronized methods internally
- C.Their state never changes, so threads cannot see a half-updated value
- D.They are stored in a special memory area
Answer & explanation
Correct answer: Their state never changes, so threads cannot see a half-updated value
With no writes after construction, there is nothing to race on.
Can you get the rest right without peeking?
Take the timed Quiz: Immutability and Value Objects quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →