1
visibility

What is the output of the following code?
public class Main{
public static void main(String args[]){
String str = “Bob”;
System.out.println(str.indexOf(‘s’));
}
}

  • Syntax error

  • Exception

  • 0

  • -1

The indexOf() method returns the value of the index if it is present. Otherwise, it returns -1;