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

Does java map allow duplicates?

905


What is java english?

1008


What is the difference between Array and Hash Table?

1033


What is logical variable?

986


How many types of memory areas are allocated by JVM in java?

1072


What is basic syntax?

1046


Can a static block throw exception?

1099


Differentiate between the constructors and methods in java?

952


What is the meaning of course?

1101


Can we overload the methods by making them static?

1004


Can java inner class be static?

1028


Difference between java and javascript

1103


Is there any difference between nested classes and inner classes?

1099


Can you start a thread twice in Java?

1123


Explain thread in java?

1171