nerdexam
Oracle

1Z0-803 · Question #18

Given the code fragment: What is the result?

The correct answer is B. Found Red. As there is no break statement after the case "Red" statement the case Blue statement will run as Note: The body of a switch statement is known as a switch block. A statement in the switch block can be labeled with one or more case or default labels. The switch statement evaluate

Using Loop Constructs

Question

Given the code fragment:

What is the result?

Exhibit

1Z0-803 question #18 exhibit

Options

  • AFound Red
  • BFound Red
  • CFound Red
  • DFound Red

How the community answered

(41 responses)
  • A
    2% (1)
  • B
    88% (36)
  • C
    2% (1)
  • D
    7% (3)

Explanation

As there is no break statement after the case "Red" statement the case Blue statement will run as Note: The body of a switch statement is known as a switch block. A statement in the switch block can be labeled with one or more case or default labels. The switch statement evaluates its expression, then executes all statements that follow the matching case label. Each break statement terminates the enclosing switch statement. Control flow continues with the first statement following the switch block. The break statements are necessary because without them, statements in switch blocksfall through: All statements after the matching case label are executed in sequence, regardless of the expression of subsequent case labels, until a break statement is encountered.

Topics

#loop constructs#conditional statements#program tracing

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice