Menu
Question Index
...

What will be the output of following program?

public class Index {
    public static void main(String args[]) {
        String s = "Below method shows how to get index of a specified character or string from the given string.";
        int i = s.indexOf('s');
        int k = s.indexOf("given");
        System.out.println("First occurence of Char 's'=" + i);
        System.out.println("First occurence of String \"given\"=" + k);
    }
}


First occurence of Char 's'=13
First occurence of String "given"=80
First occurence of Char 's'=14
First occurence of String \"given\"=79
First occurence of Char 's'=13
First occurence of String "given"=81
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