Which should be preferred between String and StringBuffer when there are many updates required to the data?
AnswerBot
2mo
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
19d
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
2mo
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
2mo
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 1w agoQ. Explain the Clonable interface.
A Java Developer was asked 1w agoQ. Explain the features of Java 21.
A Java Developer was asked 2w agoQ. How do you define custom sorting logic?
Popular interview questions of Java Developer
A Java Developer was asked 1w agoQ1. Explain the Clonable interface.
A Java Developer was asked 1w agoQ2. Explain the features of Java 21.
A Java Developer was asked 2w agoQ3. How do you define custom sorting logic?
Top HR questions asked in Infosys Java Developer
A Java Developer was asked 1mo agoQ1. If you receive negative feedback from your manager, how will you handle the situ...read more
A Java Developer was asked 1mo agoQ2. What are your long-term and short-term goals?
A Java Developer was asked 9mo agoQ3. Why Spring Boot?
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app