GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Microsoft  >  Microsoft.NET

 Print  |  
Question:  What is meant by Mutable and Immutable classes?



August 08, 2007 20:58:42 #3
 Tejas   Member Since: Visitor    Total Comments: N/A 

RE: What is meant by Mutable and Immutable classes?
 

Hi Sanjiv, I am a bit confused here.

String is a immutable class. It is advised if the value of the string
varaible is going to change from time to time then we use a StringBuilder which is a mutable class.

Hence when u change the value of as instance of string object (instance of immutable class) then new memory is created and value is stored in the new memory, where as if you assign a new value to an instance of StringBuilder class then value is changed in the same memory and this gives a performance improvement.

So in case if the string is frequently changed in the code at run time, it is advisable to use mutable objectes.

     

 

Back To Question