What is the result of the following statements? Dim strCities() As String = {“Bombay”, “Chennai”, “Ladakh”, “Tamil Nadu”} strCities(2)=”Kolkata”

Compilation Error
Runtime Error

The correct answer is D.

The statement Dim strCities() As String = {"Bombay", "Chennai", "Ladakh", "Tamil Nadu"} declares a new array of strings called strCities with four elements. The statement strCities(2)="Kolkata" assigns the string “Kolkata” to the third element of the array. Therefore, the final contents of the array are {"Bombay", "Chennai", "Kolkata", "Tamil Nadu"}.

Option A is incorrect because there is no compilation error. Option B is incorrect because there is no runtime error. Option C is incorrect because the third element of the array is “Kolkata”, not “Ladakh”.

Exit mobile version