More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Very frequently asked. Usually asked in different variants like Diff between StringBuffer , String Builder ; Difference between StringBuilder and String class; Choice between these classes etc.
Q4. What is the difference between StringBuffer and String class ?
Ans. A string buffer implements a mutable sequence of characters. A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.
The String class represents character strings. All string literals in Java programs, such as "abc" are constant and implemented as instances of this class; their values cannot be changed after they are created.
Help us improve. Please let us know the company, where you were asked this question :
Ans. List - Members are stored in sequence in memory and can be accessed through index.
Set - There is no relevance of sequence and index. Sets doesn't contain duplicates whereas multiset can have duplicates.
Map - Contains Key , Value pairs.
Help us improve. Please let us know the company, where you were asked this question :
Ans. null is a literal similar to true and false in Java. These are not keywords because these are the values of something. As null is the value of a reference variable, true is the value of a boolean variable.
Help us improve. Please let us know the company, where you were asked this question :
Ans. A compiler directive is an instruction that tells the JVM how compilation should occur. A directive provides method-context precision in controlling the compilation process.
Help us improve. Please let us know the company, where you were asked this question :