nerdexam
CIW

1D0-437 · Question #21

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…

The correct answer is C. The code will output the following: 32oz 16oz 8oz. See the full explanation below for the reasoning.

Question

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?

Options

  • AThe code will fail at line 1 because a hash cannot contain both numeric and string data
  • BThe code will execute without error but will output nothing.
  • CThe code will output the following: 32oz 16oz 8oz
  • DThe code will output the following large medium small

How the community answered

(31 responses)
  • A
    16% (5)
  • B
    6% (2)
  • C
    74% (23)
  • D
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 1D0-437 Practice