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

While creating class objects of which will be immutable. The following
things should be kept in mind:
1. Class should be made final so that no class can extend it.
2. Access modifiers of the instance variables must be private so that no
object can have access to it.
3. There should not be any public set method which can change the state of
the object.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is java console application?

1015


What is the largest number a double can hold?

1047


Why super is first line in java?

1060


What is the destroy method?

1046


What is a class variable?

1045


What is the difference between inner class and nested class?

1096


Can a abstract class be declared final?

1000


Discuss different types of errors that generally occur while programming.

1040


What is var keyword ?

1191


What is a literal coding?

1026


What does escaping a character mean?

1021


Is null in java?

1021


Difference between collection, collection and collections in java?

1014


What is the difference between a switch statement and an if statement?

1092


Explain the importance of join() method in thread class?

1098