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 are recursive functions? Give some examples?
What is bufferedreader in java?
What is the latest java version?
What are java methods?
What is a copy constructor in java?
What will happen if static modifier is removed from the signature of the main method?
Explain try and catch keywords in java?
What is pangram in java?
Difference between method overloading and method overriding in java ?
What is parsing in java?
What is currentthread()?
What is difference between Heap and Stack Memory?
How to compare strings in java?
Differentiate between == and equals().
Can we have static methods in an interface?