What output will be returned if the following Visual Basic code is executed? strCityState = “Nashville, TN” intCharIndex = strCityState.IndexOf(“Tn”)

TRUE
FALSE
11
-1

The correct answer is C. 11.

The IndexOf method returns the index of the first occurrence of a specified string within a string. The method returns -1 if the specified string is not found.

In the given code, the IndexOf method is used to find the index of the string “TN” within the string “Nashville, TN”. The string “TN” is found at index 11, so the method returns 11.

The other options are incorrect because:

  • Option A, True, is incorrect because the IndexOf method returns a number, not a Boolean value.
  • Option B, False, is incorrect because the string “TN” is found within the string “Nashville, TN”.
  • Option D, -1, is incorrect because the string “TN” is found at index 11, not at index -1.