Practice mode Java

What does it mean to say that a Java String is immutable?

Correct answer A. Its character sequence cannot change after creation

Explanation

Once a String object exists, its contents are fixed, and methods such as replace or toUpperCase return a new String instead of altering the original. The variable holding it can still be reassigned to a different object unless it is final. Immutability makes strings safe to share between threads and suitable as hash keys.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.