ICSE Class 10 Computer Applications Question 6 of 46

String Handling — Question 6

Back to all questions
6
Question

Question 2(v)

Mention the purpose and syntax of lastIndexOf() method.

Answer

The lastIndexOf() method returns the index of the last occurrence of the specified character in a string. If the character does not occur in the string, it returns -1.
Syntax:
stringObject.lastIndexOf(char)