An array is declared using the statement Dim inventory(4) As Product. Which of the following statements assigns the number 100 to the intQuantity member variable contained in the last array element?

inventory.intQuantity(4) = 100
inventory(4).Product.intQuantity = 100
inventory(3).intQuantity = 100
inventory(4).intQuantity=100

The correct answer is D. inventory(4).intQuantity=100.

The array inventory is declared with 4 elements. The last element of the array is inventory(4). The intQuantity member variable is contained in each element of the array. To assign the number 100 to the intQuantity member variable contained in the last array element, we use the following statement:

inventory(4).intQuantity=100

Option A is incorrect because it uses the wrong syntax. The syntax for accessing a member variable of an array element is:

arrayName(index).memberVariableName

In this case, the index is 4.

Option B is incorrect because it uses the wrong member variable name. The member variable name is intQuantity, not Product.

Option C is incorrect because it uses the wrong index. The index of the last element of the array is 4, not 3.

Exit mobile version