Java OCA OCP Practice Question 355

Question

Which of the following statements about a default branch in a switch statement is correct?

  • A. All switch statements must include a default statement.
  • B. The default statement is required to be placed after all case statements.
  • C. The default statement does not take a value.
  • D. A default statement can only be used when at least one case statement is present.


C.

Note

A default statement inside a switch statement is optional and can be placed in any order within the switch's case statements, making Options A and B incorrect.

Option D is an incorrect statement as a switch statement can be composed of a single default statement and no case statements.

Option C is correct because a default statement does not take a value, unlike a case statement.




PreviousNext

Related