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 / vikneswarank

String s="java";
s.repalce('j','k');

System.out.println(s);

output is: java
because String is immutable.we cannt change of string
content.suppose u have to write
s=s.repalce('j','k');

output is :kava

Is This Answer Correct ?    24 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an immutable class?

841


What is not thread safe?

743


What do you mean by scope of variable?

666


What is the method in java?

838


Can we modify the throws clause of the superclass method while overriding it in the subclass?

776


What is a variable in java?

738


Why is serialization required?

733


How do you do math powers in java?

816


How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?

766


Write a factorial program using recursion in java?

712


Convert a BST into a DLL and DLL to BST in place.

872


Can singleton class be serialized?

728


Explain hashset and its features?

824


How to convert string to byte array and vice versa?

794


Which non-unicode letter characters may be used as the first character of an identifier?

801