Page 1 of 1
Re: About Question enthuware.ocajp.i.v7.2.1193 :
Posted: Fri Nov 02, 2012 5:16 am
by Danjel
Hi
The answer seems a little wrong
if(true) break;
this would work if we are inside a for loop
for(;;){
if(true) break;
}
the answer sais when not inside a switch block, for loops is not mentioned
/Danjel
Re: About Question enthuware.ocajp.i.v7.2.1193 :
Posted: Fri Nov 02, 2012 5:42 am
by admin
Yes, it is valid in a for loop, but not within an if block (for example). That is why this option is wrong. All other options (except 1) are valid within any context.
Re: About Question enthuware.ocajp.i.v7.2.1193 :
Posted: Thu Jan 30, 2014 5:52 pm
by camillabm2
I'm just wondering... When would I use something like a switch(1)??
I can't think of a situation when it would be useful to use a constant in there.
Re: About Question enthuware.ocajp.i.v7.2.1193 :
Posted: Fri Jan 31, 2014 12:47 am
by admin
camillabm2 wrote:I'm just wondering... When would I use something like a switch(1)??
I can't think of a situation when it would be useful to use a constant in there.
I can't either. In fact, the compiler may even optimize the code and get rid of such a switch altogether.
-Paul.
Re: About Question enthuware.ocajp.i.v7.2.1193 :
Posted: Sat Aug 08, 2015 2:04 pm
by NickWoodward
admin wrote:Yes, it is valid in a for loop, but not within an if block (for example). That is why this option is wrong. All other options (except 1) are valid within any context.
in my humble opinion, for clarity....
the answer should either emphasise that the question states *when occuring by themselves*
or
it should read "Cannot have break or continue in an 'if' or 'else' block
without being inside a loop block"
otherwise it would be
very easy imo to walk away from this question thinking that breaks are never allowed in if statments, which is obviously incorrect

Re: About Question enthuware.ocajp.i.v7.2.1193 :
Posted: Sat Aug 08, 2015 9:36 pm
by admin
Added.
thank you for your feedback!
Paul.
Re: About Question enthuware.ocajp.i.v7.2.1193 :
Posted: Mon Aug 10, 2015 12:59 pm
by NickWoodward
admin wrote:Added.
thank you for your feedback!
Paul.
no worries, it's a great piece of software!