Home > Java Interview Questions > Some Interview Questions on String.

Some Interview Questions on String.

Que:-1 Difference Between String and String Buffer?

Ans:- String is a Collection or array of Characters.when u create a string object u r creating a string that can’t be changed. this approach is used becoz fixed, immutable strings can be implemented more efficiently then the muttable (Changeable Ones ) strings.

StringBuffer – StringBuffer Represents growable and writeable character sequences.StringBuffer may have characters and substrings inserted in the middle or append to end.

StringBuffer allocates room for 16 additional Characters when no specific buffer length is requested, becoz reallocation is a costly process in terms of time.

Que:-2  difference between verses (==) and .equals().

Ans.  .equals() is used for comparing values of a string objects and verses ( ==) is used to compare there memory reference.

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment