ICSE Class 10 Computer Applications
Question 5 of 46
String Handling — Question 5
Back to all questions 5
Question Question 2(iv)
Mention the purpose and syntax of indexOf() method.
The indexOf() method returns the index of the first occurrence of the specified character (passed as an argument) in a string. If the character is present in the string, the method will return the index number; otherwise, it will return -1.
Syntax:stringObject.indexOf(char)