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

The keys of %hash are sorted alphabetically: 'large', 'medium', 'small'. The loop iterates through these keys and prints their corresponding values: hash{large} (32oz), hash{medium} (16oz), and hash{small} (8oz), resulting in '32oz 16oz 8oz'.