Which of the following assigns the string “Rover” to the fifth element in a one-dimensional array named strPetNames?

”strPetNames(4)
”strPetNames[4
= “Rover”” option3=”strPetNames(5) = “Rover”” option4=”strPetNames.Items.Add(5) = “Rover”” correct=”option2″]

The correct answer is: B. strPetNames[4] = “Rover”

Option A is incorrect because it uses a square bracket ([]) instead of a parenthesis (()). A square bracket is used to access an element in an array, while a parenthesis is used to call a method.

Option C is incorrect because it uses a parenthesis (()) instead of a square bracket ([]). A parenthesis is used to call a method, while a square bracket is used to access an element in an array.

Option D is incorrect because it uses the Items property to add an element to an array. The Items property is used to access the collection of items in a list, not an array.

To assign the string “Rover” to the fifth element in a one-dimensional array named strPetNames, you would use the following statement:

strPetNames[4] = "Rover";

This statement would assign the string “Rover” to the element at index 4 in the array. The index of the first element in an array is 0, so the fifth element would have an index of 4.