Answer Posted / rashmin
To make a class immutable follow the below steips
1. Make the class Final.
2. Make the instance variables private and final.
3. Make the methods in the class also final.
By doing the above 3 we can create a fully immutable class.
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
What are the three parts of a lambda expression?
what is the purpose of "virtual"?
What are the characteristics of Final,Finally and Finalize keywords.
What do you mean by stack?
What programs use java?
What is token in java?
What does exclamation mean in java?
Have you ever used hashtable and dictionary?
Is upper case in java?
Describe 2 different ways to concatenate two strings.
What is the final method?
What will happen when using pass by reference in java?
Explain thread life cycle in java?
What is method overloading with type promotion?
How do you decide when to use arraylist and linkedlist?