What happens when a procedure containing the following statements ends? Dim decSales As Decimal=12.2 Static decTotal As Decimal=13.5

Both values lose their values
Dim variable loses its value
Static variable loses its value
Both variables retain their values

The correct answer is: D. Both variables retain their values.

A Dim variable is a local variable, which means that it is only available within the procedure in which it is declared. When the procedure ends, the value of the variable is lost.

A Static variable is a global variable, which means that it is available to all procedures in the module in which it is declared. When the procedure ends, the value of the variable is retained.

In this case, both variables are declared as Static, so their values will be retained when the procedure ends.

Exit mobile version