class output { public static void main(String args[]) { String s = "Hello World"; int i = s.indexOf('o'); int j = s.lastIndexOf('l'); System.out.print(i + " " + j); } }
Options:
A .  4 8
B .  5 9
C .  4 9
D .  5 8
Answer: Option C
indexOf() method returns the index of first occurrence of the character where as lastIndexOf()
returns the index of last occurrence of the character. output: $ javac output.java $ java output 4 9
Submit Your Solution hear: