Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Rule Roundup game - question #135 arguable wording

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Gentlemen,

Here is the question #135 in Rule Roundup game:

(#135) In switch construct, default statement will execute if no case values match switch () argument.

True
False

has a "correct" answer True, with explanation:
If there are no matching cases found, the default will run.

This is obviously true, however this is not the only case. Exactly when a case is hit, and the statement under the case and all subsequent cases doesnt have break keyword, the execution will "fall-through" to the default label, if its the last in the switch.

Am I the only one who keeps stepping into this? Maybe the wording of the question should be shuffled around a bit?

Thanks,
Ilya.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The wording seems fine to me. The question doesn't say that the statements in the default part will execute ONLY if no case label matched the switch argument. That would've been wrong. Also you can say that what if default is not there (as it is optional)....
 
This is my favorite show. And this is my favorite tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic