1.

If two arguments are passed to the indexOf() function then ___________________(a) Second argument indicates the occurrence number of specified character from starting(b) Second argument indicates the occurrence number of specified character from end(c) Second argument indicates the index of the character in first argument(d) Second argument indicates the index of the character from the last of the stringThis question was addressed to me in a national level competition.I need to ask this question from String Class topic in chapter Inbuilt Classes of Object Oriented Programming

Answer»

Right option is (a) Second ARGUMENT INDICATES the occurrence number of SPECIFIED character from starting

Explanation: The STRING may have more than one occurrence of a character. We use this function to get the index at which the specified number of times a specific character has OCCURRED in a string. For example, we can get the index of 5th occurrence of character “j” in a string.



Discussion

No Comment Found

Related InterviewSolutions