-
What is the output of this program?
public class Result
{
public static void main(String args[])
{
String a = "hello i love interview mania";
System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));
}
}
-
- 6 4 26 4
- 4 6 21 4
- 4 4 6 21
- 21 6 4 4
- 4 21 6 4
Correct Option: A
indexof(‘p’) and lastIndexof(‘p’) are pre defined function which are used to get the index of first and last occurrence of
the character pointed by p in the given array.