Java OCA OCP Practice Question 416

Question

Which statement about case statements of a switch statement is not true?

  • A. A case value can be final.
  • B. A case statement must be terminated with a break statement.
  • C. A case value can be a literal expression.
  • D. A case value must match the data type of the switch variable, or be able to be promoted to that type.


B.

Note

A case value must be a constant expression, such as a literal or final variable, so Options A and C are true statements about case values.

A case statement may be terminated by a break statement, but it is not required, making Option B the false statement and correct answer. Option D is also a true statement about case values.




PreviousNext

Related