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 methods and methodology?

523


Is 0 true or false?

510


Which of the classes will have more memory allocated?

531


What is javac used for?

509


How do you override a private method in java?

494






Define locale.

579


What is the mapping mechanism used by java to identify IDL language?

584


What is the difference between numeric and integer?

509


why doesn't java run on all platforms?

563


What are peerless components in java programming?

575


What is a wrapper method?

528


Write a program to show whether a graph is a tree or not using adjacency matrix.

586


How will you print number in reverse (descending) order in BST.

572


Can an arraylist be empty?

562


What are the default and parameterized constructors?

545