Which of the following four constructs are valid?
1. switch (5) /*from ww w.j a v a2 s .c o m*/ { default : } 2. switch (5) { default : break; } 3. switch (8); 4. int x = 0; switch (x){ }
Select 1 option
Correct Option is : D
Code 3 is invalid because a switch statement must have a body.
The body may even be empty as shown in Code 4.