Why are the objects immutable in java?



Why are the objects immutable in java?..

Answer / Viresh Kumar

"Immutable objects offer several advantages such as thread safety, predictability, and security. By making an object immutable, you ensure that its state will not be modified after it's created, thus eliminating the possibility of inconsistent or unpredictable behavior."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Marker interface means , interface which has no methods.Then what is the necessity of its usage.I read "it tells the compiler that it should be treated differently ". "It is used to store state of an object". But still am not clear.Please explain clearly.

2 Answers  


What do you understand by java virtual machine?

1 Answers  


when to use ArrayList and when to use HashMap in webApplication.

2 Answers  


What are different types of arrays?

1 Answers  


Why are constructors used?

1 Answers  


Explain spliterator in java8?

1 Answers  


How to create two different thread class inside a main function?

1 Answers  


What are adapter classes?

1 Answers  


What is api data?

1 Answers  


Is final static java?

1 Answers  


What is the use of static import ?

4 Answers   Rolta,


Does any tag exists in HTML to upload and download files ?

3 Answers  


Categories