Menu
Topics Index
...
`

Java Comes2116


If you need explanation Read this topic

If you need Answer Take test on this topic

Java Comes2116
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 = input.replace('i', 'e');
        input = input.replace("?", "");
        input1.replace('i', 'e');
        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?
Well java comes
Welcome to java  School
D. Will java comes? 
Will java comes?
E. Some other output
F. 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.

ans is B as input sring is "will java come" i replaces with e and ? with empty and prints and in input1 is "will" and i replace s with e and comes in input added to wel and concatenates java in input and school is printed

Posted by Naga Sinst    2014-05-20 13:34:36


Answer : B
> firstly we get " Well Java comes " as we replace the ? with " " and i with e
> Secondly we get " Welcome to java School " as we extract " Wel" (replace i with i) , "come" , "java " and concatinate "to" "school" thus the string "Welcome to java scholl "

Posted by Deepak Kumar Yadav    2014-05-20 13:50:51


B

Posted by Krishna Reddy    2014-05-20 14:00:54


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

Posted by Merit Campus    2014-05-21 04:08:44


© meritcampus 2019

All Rights Reserved.

Open In App