Answer Posted / tapan k dinda
To make class immutable you need to follow steps below:-
1. class should be final(strong Immutability) or all
methods final(weak Immutability)
2. all fields should be private
3. no setter/mutator should be provided
4. make deep copies of mutable data, if any
any confusion plz mention in your next post.
Is This Answer Correct ? | 10 Yes | 2 No |
Post New Answer View All Answers
Is array passed by reference in java?
How are destructors defined in java?
List some important features of java 10 release?
What are the ways to instantiate the class class?
What is an i/o filter?
java Technical questions asked by JPMC
Is age a discrete variable?
What are different types of states exist for a thread?
Explain when noclassdeffounderror will be raised ?
Is there any sort function in java?
Implement a stack with push (), pop() and min() in O(1) time.
What is are packages?
placement papaers of spring computing technology
Which collection is ordered in java?
How to set the permissions to a file in java?