Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to make a class immutable?

Answer Posted / raga

While creating class objects of which will be immutable. The following
things should be kept in mind:
1. Class should be made final so that no class can extend it.
2. Access modifiers of the instance variables must be private so that no
object can have access to it.
3. There should not be any public set method which can change the state of
the object.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does super keyword do?

1071


Is string serializable in java?

1014


What is the difference between multiple processes and multiple threads?

1202


What are operators and its types?

1064


When a lot of changes are required in data, which one should be a preference to be used? String or stringbuffer?

1238


Explain differences between checked and unchecked exceptions in java?

1060


What are the 4 versions of java?

1161


Difference between linkedlist and arraylist.

1068


What is dynamic binding(late binding)?

1041


What is variable and its types?

1009


What is meant by data hiding/encapsulation?

1104


Does unicode support all languages?

1029


What is a conditional equation?

1041


What is executor memory?

943


What are the differences between Java 1.0 and Java 2.0?

2265