Courseiva
Control Flow and LoopshardMultiple SelectObjective-mapped

1Z0-811 Control Flow and Loops Practice Question

Which three statements about the switch statement in Java are true?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

a break statement is optional

Options A, B, and D are true. A: The break statement is optional; without it, execution falls through to the next case. B: char can be used as the switch expression type because char is an integer-compatible type. D: The default case executes when no other case matches. C is false because only one default case is allowed. E is false because boolean is not allowed as a switch expression.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • a break statement is optional

    Why this is correct

    A `break` statement is indeed optional within a Java `switch` block, satisfying the 'true' constraint. Its omission results in "fall-through" behaviour, where execution continues into subsequent `case` blocks until a `break` is encountered or the `switch` block ends. This deliberate design allows for scenarios where multiple `case` labels should execute the same code, making `break` a control flow choice rather than a mandatory syntax element.

  • switch can use char as the expression type

    Why this is correct

    char is allowed because it is promoted to int.

  • the switch statement can have multiple default cases

    Why it's wrong here

    Only one default case is allowed.

  • the default case is executed when no other case matches

    Why this is correct

    default handles any unmatched values.

  • switch can use boolean as the expression type

    Why it's wrong here

    boolean is not a valid type for switch.

About these practice questions

This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

2 more ways this is tested on 1Z0-811

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Which TWO statements are true about the switch statement in Java? (Choose two.)

easy
  • A.It can be used with char variables.
  • B.The break statement is mandatory at the end of each case.
  • C.The default case is optional.
  • D.Case labels can be runtime expressions.
  • E.It can be used with long variables.

Why A: Options A and C are correct. A: Switch supports char, int, short, byte, String, and enum types, so char is valid. B is false because the break statement is optional; without it, execution falls through to the next case. C is true: the default case is optional. D is false because case labels must be compile-time constant expressions, not runtime expressions. E is false because long variables are not allowed in switch statements.

Variation 2. Which THREE statements are true about the switch statement in Java? (Choose three.)

medium
  • A.It can be used with boolean expressions.
  • B.The default case must be placed at the end of the switch block.
  • C.Without a break statement, execution falls through to the next case.
  • D.The default case is optional.
  • E.It can be used with String objects.

Why C: Options C, D, and E are true. Option C correctly describes fall-through behavior: without a break statement, execution continues to the next case. Option D correctly states that the default case is optional. Option E is true because, since Java 7, the switch statement can be used with String objects. Options A and B are false: A is incorrect because switch does not support boolean expressions; B is incorrect because the default case can appear anywhere in the switch block.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.