What is wrong with the following statement? Dim strCities As String = {“Bombay”, “Chennai”, “Ladakh”, “Tamil Nadu”}
static keyword missing
array elements should be initialized using single quotes
array elements should be in square brackets
array name should be strCities()
Answer is Wrong!
Answer is Right!
The correct answer is: C. array elements should be in square brackets
The statement Dim strCities As String = {"Bombay", "Chennai", "Ladakh", "Tamil Nadu"}
is trying to create an array of strings, but it is missing the square brackets []
that are required to specify the array elements. The correct statement would be:
Dim strCities As String() = {"Bombay", "Chennai", "Ladakh", "Tamil Nadu"}
Option A is incorrect because the static
keyword is not required to declare an array. Option B is incorrect because string literals are always enclosed in double quotes. Option D is incorrect because the array name does not need to be enclosed in parentheses.