QuestionQ146

Using Loop Constructs

Given the following code fragment:

Question Image

Which code fragment outputs red:blue:small:medium?

  • A
  • B
  • C
  • D
Explanation

Nested enhanced for loops traverse a two-dimensional array row by row: the outer loop obtains each String[] row, and the inner loop prints every String in that row. This produces the elements in order as red, blue, small, and medium, each followed by a colon.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!