Java SE 8 Programmer I — Question 162

Which statement is true about the switch statement?

Answer options

Correct answer: B

Explanation

The correct answer is B because the break statement is optional; omitting it allows execution to continue into the next case. Option A is incorrect as the default section is not mandatory. Option C is wrong because case labels are fixed at compile time and cannot be changed at runtime. Option D is also incorrect since the expression must evaluate to a single value, not a collection.