Menu
Question Index
...

What will be the output of following program?

public class StringReplace {
    public static void main(String args[]) {
        String office1 = "This is my office,my office is so good";
        String search = "office";
        String output = "";
        int x = office1.indexOf(search);
        output = office1.substring(x, office1.length() - 5);
        System.out.print(output);
    }
}


office,my office is so
office,my office is so goo
office,my office is
office,my office is so good
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java String substring() method - substring In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App