Join Examsbook
1080 0

Q: What is immutable object? Can you write immutable object ?

  • Show AnswerHide Answer
  • Workspace

Answer :
Explanation :

Immutable classes are Java classes whose objects can not be modified once created. Any modification in Immutable object result in new object. For example is String is immutable in Java. Mostly Immutable are also final in Java, in order to prevent sub class from overriding methods in Java which can compromise Immutability. You can achieve same functionality by making member as non final but private and not modifying them except in constructor.

Are you sure

  Report Error

Please Enter Message
Error Reported Successfully