Multiple choice technology programming languages

If you wanted to find out where the position of the letter v (ie return 2) in the string s containing "Java", which of the following could you use?

  1. mid(2,s);

  2. charAt(2);

  3. s.indexOf('v');

  4. indexOf(s,'v');

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The indexOf method returns the position of a specified character or substring within a string. For the string "Java", indexOf('v') returns 2 because it's zero-indexed (J=0, a=1, v=2). Option A and B reference non-existent methods, and option D has incorrect parameter order.