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 .
Select
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.
Infosys Java Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits