Difference String and String Buffer
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
Answer / a kumar
String buffers are safe for use by multiple threads
| Is This Answer Correct ? | 0 Yes | 2 No |
Can static method access instance variables ?
What is difference between overloading and overriding?
interface X{ void m1(); void m2(); } class Child2 extends Object implements X { public void m1(){ System.out.println("Child2 M1"); } public void m2(){ System.out.println("Child2 M2"); } } public class ParentChildInfterfaceDemo { public static void main(String[] args){ X x = new Child2(); X x1 = new Child2(); x.m1(); x.m2(); x.equals(x1); } } Will the above code work? If yes? Can you please explain why the code x.equals(x1) will work as the equals method is called on interface reference vaiable?
What does exp mean in math?
java is puerly object oriented or not ?
What do you know about the garbate collector?
class A{ some variables; public void a()throws Excepion1,Exception2{....} } class B extends A{ variables... public void a()throws E2,E3{.....} } Qns: here override of methods occurs or not,ore else wil give any compilation error or run properly..plz tell me briefly whts happening with the above codes....
What is the use of StringTokenizer class?
What is the definition of tree ?
If you do not want your class to be inherited by any other class. What would you do?
Can we inherit inner class?
Explain the use of shift operator in java. Can you give some examples?