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.
Ans. String has an argument constructor that take char array as argument and creates a string.
There is no constructor available with String that takes in a character and creates a String. We can use StringBuilder which has a char argument constructor.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  character  char  char array  String  char to String  char array to String
Q76. Why shouldn't we use string concatenation extensively or in a loop ?
Ans. Because String being an immutable object creates a new object upon each concatenation cycle. If there is any such need , we should use String Builder whose objects are mutable.
Help us improve. Please let us know the company, where you were asked this question :
Q77. Suppose we have a string "Java is object oriented language" and we have to reverse every alternate word in string. How would we do that using Java program.
Q78. Given a String with letters , numbers and special characters , extract Tokens from it. The rules for Token extraction are ac follows
1. Should for token of all characters till a number or special character is found
2. Should form token of all numbers till a character or special character is found
3. Special character in itself is a token
4. Ignore white spaces
For example - Bob Said "He is here"
should result in
Bob A
Said A
" S
He A
is A
here A
" S
where a is specifying alphabet and S as special character
Ans. It depends on how complex it is and if in future it would need any sort opf debugging. It's not easy to debug code if it's making heavy use of shortcuts like Lambda , Patterns etc.
Help us improve. Please let us know the company, where you were asked this question :