I am confused about the answer choice B for this question, which is false. Can someone explain why , please, thanks! ---------------------------------------------------------------- 1. which of the following are true for a switch statement? A]all switch statements must have a default label B]there must be atleast one label for each code segment C]keyword continue can never occur D]no case label may follow a default label E]char literal can be used
A]all switch statements must have a default label -> False B]there must be atleast one label for each code segment -> False C]keyword continue can never occur -> True D]no case label may follow a default label -> False E]char literal can be used -> True
sarim raza
Ranch Hand
Joined: Nov 02, 2000
Posts: 232
posted
0
thanks sapna,can you please explain why B is false and also are you sure that there cant be a continue in a switch statement. thanks!
Hi! Sarim u have asked why the answer is false for this question. well---> B]there must be atleast one label for each code segment
The structure for a switch case statement is: Switch(value) case 1:{-------} case 2:{-----} default{----} Now if there were to be no case statement present for each code statement enclosed in brackets (-----) , then the switch statement cannot execute unless default is present.