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

How variables are stored in memory?

998


What is a container in a gui?

981


What does n mean in java?

964


What is tcp and udp?

1010


What is the internal implementation of set in java?

924


What are the basic interfaces of java collections framework?

1113


What are constants?

1051


How many bytes is a string java?

1019


What restrictions are placed on method overloading?

1173


Is null a string or object in java?

962


What is the main method java?

1028


what are Hostile Applets?

2076


What is a copy constructor in java?

1118


What are the differences between throw and throws?

1073


State some advantages of java?

1224