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 fileinputstream and fileoutputstream?
Can static methods be inherited?
How will you reverse a link list without using recursion?
Give me some null interfaces in java?
How do you identify independent and dependent variables?
How to write custom exception in java?
What is overloading and overriding in java?
How to sort an array from smallest to largest java?
What is the loop in java?
What is the use of pattern in java?
Name container classes in java programming?
How do you declare an empty string?
What is a module function?
What is finalize() function in java?
In case of inheritance what is the execution order of constructor and destructor?