Q. Why are String objects in Java considered immutable?

A
They can be changed after creation
B
Their value cannot be changed after they are created
C
They can only store numeric characters
D
They are a primitive data type
Solution:

Immutability means that once a String object is created, its internal state (the sequence of characters) cannot be altered. Any operation that seems to modify a string actually creates a new String object.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!