I have a String s = java; What is the output when I say
s.replaceAll('j', 'k'); Also what is the value of s after
replacing?
Answer Posted / prachi
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method replaceAll(String, String) in the type String is not applicable for the arguments (char, char)
will be thrown because in replaceAll(‘j’,’k’) : j & k are in single quote which defines as character not as string. For correct output first replace single quote with double quotes and second write s = s.replaceAll(“j”, “k”);
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is difference between add() and addelement() in vector?
What is autoboxing in java?
Explain spliterator in java8?
What type of variable is error flag?
Where are global variables stored?
What is type safety in java?
Which api is provided by java for operations on set of objects?
What exactly is methodology?
When should we create our own custom exception classes?
How can you handle java exceptions?
What is a parameter used for?
What do you understand by weak reference?
What is private protected in java?
Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?
What is slash r?