Menu
Question Index
...

What will be the output of the following program?

public class Flowers {
    public static void main(String[] args) {
        String strName;
        int number;
        strName = "Rose";
        number = strName.indexOf("rose");
        System.out.println("Output is " + number);
    }
}


Output is 0
Output is 1
Output is 4
Output is -1
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Searching Strings - Java indexOf, lastIndexOf Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App