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


Please Help Members By Posting Answers For Below Questions

What is difference between add() and addelement() in vector?

1310


What is autoboxing in java?

825


Explain spliterator in java8?

813


What type of variable is error flag?

840


Where are global variables stored?

710


What is type safety in java?

743


Which api is provided by java for operations on set of objects?

1203


What exactly is methodology?

696


When should we create our own custom exception classes?

806


How can you handle java exceptions?

740


What is a parameter used for?

744


What do you understand by weak reference?

759


What is private protected in java?

794


Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?

782


What is slash r?

768