Search Java Interview Questions
| 2252 questions in repository.|
There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Interview Questions and Answers for 'San Jose State University (SJSU)' - 1 question(s) found - Order By Newest|
|Very frequently asked in different variations. Frequently asked in Deloitte ( 2 feedback ) , HCL Tech ( 3 feedback ) and Coginizant (CTS)|
|Ans. If the Object value will not change, use String Class because a String object is immutable.|
If the Object value can change and will only be modified from a single thread, use StringBuilder because StringBuilder is unsynchronized(means faster).
If the Object value may change, and can be modified by multiple threads, use a StringBuffer because StringBuffer is thread safe(synchronized).
Sample Code for String
Sample Code for StringBuffer
Sample Code for StringBuilder
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve java string class string stringbuilder stringbuffer Cognizant (CTS) San Jose State University (SJSU) HCL Technologies Deloitte Sophos Hitachi JPMorgan Chase IBM Kony Labs Keystone ebay TIAA Financial Services Ancestry Rakuten basic   frequent|
Try 3 Question(s) Test
|Difference between == and .equals() ?|
|Why is String immutable in Java ?|
|What are different ways to create String Object? Explain.|
|How does making string as immutable helps with securing information ? How does String Pool pose a security threat ?|
|Why Char array is preferred over String for storing password?|
|How is string object immutable if we can concat a string to it ?|
|What is StringJoiner ?|
| Which of the following is false about main method ?|
a. It should be declared public and static
b. it should have only 1 argument of type String array
c. We can override main method
d. We can overload main method
|Which String class does not override the equals() and hashCode() methods, inheriting them directly from class Object?|