Hello Friends, In this blog post, I am going to let you know about a few more questions of core java related to String buffer and String builder.
Core java interview questions covers all the important questions of the topics mentioned above.
These core java interview questions is a great help to remember all the important highlights and important topics from each java chapter.
These interview questions will surely help to understand a few very confusing concepts in java.
What is the difference between string and string buffer classes in java?
String class objects are immutable and hence their contents cannot be modified, string buffer class objects are mutable, so they can be modified, moreover, the methods that directly manipulate data of the object are not available in the string class. Such methods are available in the StringBuffer class.
Are there any other classes whose objects are immutable?
Yes, classses like character, byte, integer, float, double, long, … called wrapper classes are craeted as immutable classes like class, biginteger bigdecimal are also immutable.
What is the difference between string buffer and string builder classes?
String buffer class is synchronized and string builder is not. When the programmer wants to use several threads, he should use string buffer as it gives reliable results. If only one thread is used, string builder is preffered, as it imporves execution time.
So this was all about the Core java interview questions in this topic.
These Core java interview questions could be a great help in your college viva, academic study, and any job interview.
In the case of any queries, you can write to us at [email protected] we will get back to you ASAP.
Hope! you would have enjoyed this post about Core Java Interview Questions Part 7/ String buffer and String builder.
Please feel free to give your important feedbacks in the comment section below.
Have a great time!