English

Give the output of the following string methods. "MISSISSIPPI".indexOf('s') + "MISSISSIPPI".lastIndexOf('I')

Advertisements
Advertisements

Question

Give the output of the following string methods.

"MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')

Options

  • 10

  • 12

  • 20

  • 11

MCQ
Advertisements

Solution

12

Explanation:

"MISSISSIPPI" .indexOf('S') returns 2, the first index of 'S' + "MISSISSIPPI".lastlndexOf('I') returns 10, the last index of 'I' = 12

shaalaa.com
  Is there an error in this question or solution?
2021-2022 (March) Set 1
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×