
Asked in Infosys
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
5mo
Kindly read the question first he was talking about string not string builder .
Add answer anonymously...
Top Java Developer Interview Questions Asked at Infosys
Q. How can you reverse a string using the Stream API?
Q. What is a profiler?
Q. What is REST API?
Interview Questions Asked to Java Developer at Other Companies
Top Skill-Based Questions for Infosys Java Developer
Java Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Algorithms Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Spring Boot Interview Questions and Answers
50 Questions
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

