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 class immutable

Answer Posted / kanchan

1. Don't provide any methods that modify the object
2. Ensure that no methods may be overridden. This prevents
careless or malicious subclasses from compromising the
immutable behavior of the class. Preventing
method overrides is generally done by making the class final
3. Make all fields final.
4. Make all fields private. This prevents clients from
modifying fields directly.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is private public protected in java?

1024


What are constructors in java?

1076


Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?

1031


Can you start a thread twice in Java?

1100


What is thread pool in java with example?

986


What is the difference between char and char *?

1060


What is the difference between JDK and JVM?

1241


Can we override final method?

986


What is ctrl m character?

1039


What does 3 dots mean in java?

968


What are the main uses of this keyword?

1038


What is the full name of java?

1102


What is use of valueof () in java?

1034


how would you implement a thread pool? : Java thread

890


Explain super keyword in java.

1025