Which should be preferred between String and StringBuffer when there are many updates required to the data?

AnswerBot
4mo
String should be preferred for frequent updates due to its immutability.
String is immutable, so every update creates a new instance, leading to memory overhead.
StringBuffer is mutable and allows for e...read more
Dhanu Baddela
2mo
String is immutable, meaning every modification (like concatenation) creates a new object in memory. Frequent updates using String lead to performance issues, increased memory usage, and garbage colle...read more
Anonymous
4mo
StringBuffer.
RaviRamKiran Bharadwaj
1y
It is recommended to use StringBuilder whenever possible because it is faster than StringBuffer. However, if the thread safety is necessary, the best option is StringBuffer objects
Anonymous
4mo
Kindly read the question first he was talking about string not string builder .
Add answer anonymously...
Infosys Java Developer interview questions & answers
A Java Developer was asked 4w agoQ. What is a profiler?
A Java Developer was asked 1mo agoQ. What is the MVC architecture?
A Java Developer was asked 2mo agoQ. Explain the features of Java 21.
Popular interview questions of Java Developer
A Java Developer was asked 4w agoQ1. What is a profiler?
A Java Developer was asked 1mo agoQ2. What is the MVC architecture?
A Java Developer was asked 2mo agoQ3. Explain the Clonable interface.
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

