Multiple choice technology programming languages

After the following code fragment, what is the value in a? String s; int a; s = "Foolish boy."; a = s.indexOf("fool");

  1. -1

  2. 0

  3. 4

  4. none

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

The indexOf method is case-sensitive. Since the string s contains "Foolish boy." with an uppercase 'F', searching for the lowercase substring "fool" yields no match, returning -1.