Menu
Topics Index
...
`

String Replace


If you need explanation Read this topic

If you need Answer Take test on this topic

String Replace
What will be the output of the following program?
public class JavaComes {
    public static void main(String[] args) {
        String input = "Will java comes?";
        String input1 = input.substring(0, 3);
        input.replace('i', 'e');
        input.replace("?", "");
        System.out.println(input);
        input1 = input1.replace('i', 'e') + input.substring(10, 14) + " to " + input.substring(5, 10) + " School";
        System.out.println(input = input1);
    }
}

A. Will java comes?
Welcome to java  School
B. Well java comes
Welcome to java  School
C. Will java comes?
Will java comes?
D. Some other output
E. Compilation Error or Runtime Error
Topic: replace() Method In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

A. is the ans.as first SOP jst prints input contents.and next w r rplcng i with e and adding substing of comes.

Posted by Shabaaz Shaikz    2014-06-09 13:04:28


ans b. input i replcd e and ? replacd " ".thn printd.

Posted by Maheshwari Natarajan    2014-06-09 13:43:41


Ans is b ...Initially,i is replaced with e and ? is replaced with a space..Next print statement contains wel initially and after it is concatenated with substrings come,to,java and school...So it prints out Welcome to java School and the final answer is Well java comes\nWelcome to java School

Posted by Badam Swathi    2014-06-09 14:25:30


Congratulations Shabaaz Shaikz. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-06-10 11:37:47


© meritcampus 2019

All Rights Reserved.

Open In App