nerdexam
CIW

1D0-437 · Question #4

Consider the following program code: %hash = ("small" -> "Boz", "medium" => "16oz", "large" => "32oz"); @keys = sort(keys(%hash)); for ($i = 0; $i < 3; $i++) { print("$hash{$keys[$i]}\n"); } What is…

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

Question

Consider the following program code:

%hash = ("small" -> "Boz", "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 will output the following 32oz 16oz 8oz
  • DThe code will output the following large medium small

How the community answered

(25 responses)
  • A
    12% (3)
  • B
    8% (2)
  • C
    76% (19)
  • D
    4% (1)

Community Discussion

No community discussion yet for this question.

Full 1D0-437 Practice