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 instance example?

927


What exactly is a .class file?

1000


What's the base class of all exception classes?

1026


What is the generic function?

941


What is abstract class constructor called?

962


What is the purpose of garbage collection in java? When is it used?

1011


How to use string tokenizer class.

1148


Explain about instanceof operator in java?

1005


What are the three best choices for a development environment?

1070


What about abstract classes in java?

1026


What is singleton class and how can we make a class singleton?

1069


How do you end a program?

1054


How to find the largest value from the given array.

976


What are the main uses of this keyword?

1008


What is the properties class in java programming?

958