SynergisticIT interview question

make immutable class

Interview Answer

Anonymous

16 Jun 2017

To create immutable class in java, you have to do following steps. 1. Declare the class as final so it can't be extended. 2. Make all fields private so that direct access is not allowed. 3. Make all mutable fields final so that it's value can be assigned only once.

3