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
Which is faster call by value or call by reference?
What are the object and class classes used for?
Can we override constructors?
Can we have any code between try and catch blocks?
Can an abstract class be a final class?
What is the implementation of destroy method in java. Is it native or java code?
What is the use of object and class classes?
Why are parameters used in functions?
How do you create a first line indent?
Can we force garbage collector to run ?
What is keyword auto for?
What is the meaning of immutable regarding string?
How do you clear a method in java?
Name few java 8 annotations ?
What is the difference between @before and @beforeclass annotation?