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 / cm

1. Mark the class as 'final' to avoid any
subclassing/overriding
2. Make the fields as 'private' & 'final' to avoid
reassining in any way after creation of the object by
passing params via contructor

Is This Answer Correct ?    17 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What types of index data structures can you have in java?

1318


Explain naming conventions for packages?

1092


What is the full meaning of java?

1098


Is arraylist a class in java?

1127


Why do we create threads in java?

1351


Explain about map interface in java?

1052


what is the difference between Object Based Language and Object Oriented Language?

1087


Why is the type for real numbers called double?

1018


What is empty string literal in java?

1111


What are default methods ?

1109


Is map sorted in java?

1114


Can arraylist hold different types java?

1038


How to disable caching on back button of the browser?

1139


What is function declaration?

1024


How many bytes is a string?

1180