Java OCA OCP Practice Question 823

Question

Which of the following variable types is permitted in a switch statement? (Choose three.)

  • A. Character
  • B. Byte
  • C. Double
  • D. long
  • E. String
  • F. Object


A, B, E.

Note

A switch statement supports the primitive types byte, short, char, and int and their associated wrapper classes Character, Byte, Short, and Integer.

It also supports the String class and enumerated types.

Floating-point types like float and double are not supported, nor is the Object class.

For these reasons, Options A, B, and E are correct.




PreviousNext

Related