• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Wrong answer in the JavaRanch Rule Round-up Game

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question #135 should be corrected.

Answer can be "false" because there is no information about break statement.
So the default statement will execute even a case value matches switch() argument, for example:

javaranch_game2_135.png
[Thumbnail for javaranch_game2_135.png]
Question #135
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From where you get this question. This is not the right forum to post it. What is the complete question? Because if no match found then also default case will be executed.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch, and thanks for the feedback!

I believe the answer is correct as it stands. It says that the default clause will execute if no case matches, and that's absolutely true. It's possible that the default will execute if a case matches, also -- but that doesn't make the original statement false. If the question had said "True or false: the default clause will only execute if no case matches", then I would agree with you, but it does not say that.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pramod P Deore wrote:This is not the right forum to post it.



As he says in the subject line, it's from the JavaRanch Rules Roundup Game, and this is absolutely the right place to post this.
 
Sergey Zakusov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pramod P Deore wrote:From where you get this question.


http://www.javaranch.com/game/game2.jsp

Pramod P Deore wrote:This is not the right forum to post it.


Paul Wheaton said me to post it here.

Pramod P Deore wrote:What is the complete question? Because if no match found then also default case will be executed.


It's not a question. It's just a proposal.
 
Sergey Zakusov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ernest Friedman-Hill wrote:If the question had said "True or false: the default clause will only execute if no case matches", then I would agree with you, but it does not say that.


Ok. You are right.
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Sergey , Actually I don't know about the JavaRanch Rule Round-up Game therefore I had asked that questions. but now I got my mistake. Thanks I will also check JavaRanch Rule Round-up Game.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sergey Zakusov wrote:Ok. You are right.

EFH usually is.
 
Grow your own food... or this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic