← Quiz: Java Strings: all 10 questions
Quiz: Java Strings · Question 4 of 10
Why are Java Strings immutable? (pick the best reason)
Why are Java Strings immutable? (pick the best reason)
- A.To use less memory per character
- B.So they can be safely shared (string pool) and are thread-safe
- C.Because Java has no arrays
- D.To make them faster to change
Answer & explanation
Correct answer: So they can be safely shared (string pool) and are thread-safe
Immutability allows pooling, caching and safe sharing between threads.
Can you get the rest right without peeking?
Take the timed Quiz: Java Strings quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →