Difference between String and String Buffer?

Answers were Sorted based on User's Feedback



Difference between String and String Buffer?..

Answer / janet

1. String objects are constants and immutable where as
StringBuffer objects are not.
2.String class supports constant strings where as
StringBuffer class supports growable and modifiable strings.

Is This Answer Correct ?    13 Yes 0 No

Difference between String and String Buffer?..

Answer / sumati

String is immutable
String buffer is mutable

Ex String str = "abc";
str = "new String";
this will creat new memory location and stores "new String"

but in String buffer
StringBuffer strBuf = "abc";
strBuf = "new String"

it will overwrite in same memory location

Is This Answer Correct ?    13 Yes 0 No

Difference between String and String Buffer?..

Answer / ravikiran(aptech mumbai)

string is immutable
string buffer is mutable

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More Core Java Interview Questions

Can I overload to string method

0 Answers   UHG,


Functionality of JVM?

7 Answers   Infosys,


What is quick sort in java?

0 Answers  


Does constructor creates the object ?

0 Answers  


what is difference between throw and throws in exception?

48 Answers   Spenco,






class A { private int i; } class B extends A { private int i; } if I create an object of B class what will be the memory of that object.

2 Answers   Yamaha,


Can you explain the meaning of aggregation and composition

0 Answers  


How can we find the sum of two linked lists using stack in java?

0 Answers  


What are the parameters used in Connection pooling?

1 Answers   IBM,


what is Assertion?

4 Answers   Wipro,


What are some examples of variable costs?

0 Answers  


When to use runnable interface vs thread class in java?

0 Answers  


Categories