Question
class output {
public static void main(String args[])
{
String a="hello i love java";
System.out.println(indexof('i')+" "+indexof('o')+" "+lastIndexof('i')+" "+lastIndexof('o') ));
}
}
What is the output of this program?
class output {
public static void main(String args[])
{
String a="hello i love java";
System.out.println(indexof('i')+" "+indexof('o')+" "+lastIndexof('i')+" "+lastIndexof('o') ));
}
}
Answer: Option A
Was this answer helpful ?
indexof('c')and lastIndexof('c')are defined function which are used to get the index
of first and last occurrence of
the character pointed by c in the given array.
Output:
$ javac output.java
$ java output
6 4 6 9
Was this answer helpful ?
Submit Solution