JavaChallenge27

#SwitchCase #JavaChallenge

Try to solve the challenge by yourself first!

Observations & Questions
1. switch() does not have any expression so, it will be executed for constant value which is 3 .
2. None of the cases has a break statement, so loop will execute all cases from the first match.
3. The default statement is not the last case so, it can be executed or can throw compile-time error???

The position ofdefault does not create any problem to compiler because the compiler treats the default statement as one of the cases so it will not throw a compile-time error. Now, the obvious answer is 5 .

Let me know if you liked the challenge.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store