Full Stack Developer (Java) Question:

Download Job Interview Questions and Answers PDF

Explain me what is the difference between String, StringBuffer andStringBuilder?

Full Stack Developer (Java) Interview Question
Full Stack Developer (Java) Interview Question

Answer:

String is an immutable class. In older JDK’s the recommendation when programmatically building a String was to use StringBuffer since this was optimized to concatenate multiple Strings together. However, the methods on StringBuffer were marked as sychronized, which meant that there was a performance penalty, hence StringBuilder was introduced to provide a non-synchronized way to efficiently concatenate and modify Strings.

Download Full Stack Developer (Java) Interview Questions And Answers PDF

Previous QuestionNext Question
Explain me something About Your Favorite Language And Why?Please explain what is the contract between equals and hashCode of an object?