Difference String and String Buffer

Answers were Sorted based on User's Feedback



Difference String and String Buffer ..

Answer / parameswaran

String is immutable object..we can't modified the value...
but string buffer is mutable object we can change.
>>It can increase or decrease the size dynamically..
>>It contains Max 255 characters..

Warm & Regards
Parames(PRC)

Thanjavur

Is This Answer Correct ?    6 Yes 0 No

Difference String and String Buffer ..

Answer / kanchan

String are read only and immutable. The StringBuffer class
is used to represent characters that can be modified.
StringBuffer is faster than String when performing simple
concatenations.

Is This Answer Correct ?    4 Yes 0 No

Difference String and String Buffer ..

Answer / gangabusi

String is immutable, we can not modify the string objects.
if we can create any string object
Ex: String S="Ganga";
here 'S' is string object created in heap memory.

I Want to add Something to S,
String S="Gangadhar";

Here In heap momory one more object is created for 'S',not
overridden.So that each and every updation String create
one new object in heap.



StringBuffer sb="Ganga"

here 'sb' is stringbuffer object created in heap memory.

I Want to add Something to sb,
StringBuffer sb="Gangadhar";

Here In heap momory 'sb' is overridden.So that each and
every updation StringBuffer create an object in stack.


It is mutable and it is Synchronized.(one thread process at
a time)

Is This Answer Correct ?    2 Yes 0 No

Difference String and String Buffer ..

Answer / a kumar

String buffers are safe for use by multiple threads

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Core Java Interview Questions

Explain what do you mean by functional overloading in java?

0 Answers   Maveric, Verifone,


What is difference between array and arraylist in java?

0 Answers  


Define Multiprogramming and Multiprocessing in java.

0 Answers   Akamai Technologies,


Explain different types of thread priorities ?

0 Answers  


How to do encapsulation in java?

0 Answers  






What does n mean in java?

0 Answers  


What is the use of predicate in java 8?

0 Answers  


Justify your answer that you can't define a method inside another method in java, if you can then how?

0 Answers  


Same common question what is Map,Set,HashMap,List????

4 Answers   Symphony,


Why Java is not pure Object Oriented language?

0 Answers  


Can keyword be used as identifier?

0 Answers  


What is file class and what is its purpose?

1 Answers  


Categories