Multiple choice technology programming languages

Consider the following program code: %hash = (small => 8oz, medium => 16oz, large => 32oz); @keys = sort(keys(%hash)); for (\$i = 0; \$i < 3; \$i++) { print(\$hash{\$keys[\$i]}\n); } What is the result of executing this program code?

  1. The code will fail at line 1 because a hash cannot contain both numeric and string data.

  2. The code will execute without error but will output nothing.

  3. The code will output the following:32oz 16oz 8oz

  4. The code will output the following:large medium small

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Sorting the hash keys (large, medium, small) alphabetically yields the order: large, medium, small. Iterating through this sorted list and printing the corresponding hash values outputs 32oz, 16oz, and 8oz in sequence. The other options are incorrect because the code is syntactically valid (with barewords treated as strings) and produces this specific output.