Fidelity Investments Interview Question: Difference between String and... | Glassdoor

Interview Question

Quality Assurance Engineer Interview(Student Candidate) Durham, NC

Difference between String and Stringbuilder in Java. (Phone

  screen question)

Interview Answer

1 Answer


String objects are immutable.
Consider an example,
String s= "test";
The above code creates a second object for concatenation internally which is a performance issue.
Consider a string buffer,
StringBuilder sb = new StringBuilder("test");
Both of them perform the concatenation operation but using String class which is immutable gives rise to performance issues where as StringBuilder class is mutable and updates the existing object!

CK on Nov 24, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.