Answer Posted / kanchan
To make a class immutable,
1. Don't provide any methods that modify the object.
2. Ensure that no methods may be overridden. Mark the class
as final. Make all fields final and private.
Is This Answer Correct ? | 63 Yes | 1 No |
Post New Answer View All Answers
What is the difference between a synchronized method and a synchronized block?
What are the different data types in java?
Are variables stored in ram?
What is classpath?
How does thread synchronization occurs inside a monitor?
Differentiate between vector and array list.
What is foreach loop in java?
What are pass by reference and pass by value?
What happens if a constructor is declared private?
Do I need java on my computer?
How can you make a class serializable in java?
What is hasnext in java?
What is singleton service?
How do I write a self declaration?
Why spring singleton is not thread safe?