🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)

  1. A.To use less memory per character
  2. B.So they can be safely shared (string pool) and are thread-safe
  3. C.Because Java has no arrays
  4. 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 →