Home » JAVA Programming » Strings » Question
  1. What is the output of this program?

    public class output
    {
    public static void main(String args[])
    {
    String str1 = "Intervzew Manza";
    String str2 = str1.replace('z','i');
    System.out.println(str2);
    }
    }
    1. Intervzew
    2. Manza
    3. Interview Mania
    4. IntervzewManza
    5. None of these
Correct Option: C

replace() method replaces all occurrences of one character in invoking string with another character. str1.replace(‘z’,’i’) replaces every occurrence of ‘z’ in hello by ‘i’, giving Interview Mania.



Your comments will be displayed only after manual approval.