Mark Kevin wrote:According to the exam watch, the first code snippet violates a rule for the switch and case arguments because it "uses a curly brace ...". However when I compile and run it all works fine, and according to StackOverflow, while not using curly braces in a case might make the code more readable with respect to scope, and such, it is not really an illegal violation. Also, shouldn't "uses a curly brace" be plural, ie., "uses curly braces" ? Since there are two of them... Or, perhaps they intended for there to be one curly brace missing in the case in the first example?
You should look more carefully at the code snippet. There's nothing wrong with the curly braces. Something else is missing and that's why the code snippet fails to compile.
Mark Kevin wrote:Also, the second snippet uses curly braces and it compiles and runs fine.
The 2nd code snippet fails to compile as well. It uses curly braces as well, but again something else is missing. Again look more closely!
Having an eye for detail is very important when you take the actual exam! And this Exam Watch shows why
Hope it helps!
Kind regards,
Roel