About Question enthuware.ocajp.i.v7.2.1193 :
Moderators: Site Manager, fjwalraven
-
- Posts: 4
- Joined: Tue Oct 16, 2012 8:21 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1193 :
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
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
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1193 :
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Thu Jan 30, 2014 5:50 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1193 :
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 think of a situation when it would be useful to use a constant in there.
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1193 :
I can't either. In fact, the compiler may even optimize the code and get rid of such a switch altogether.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.
-Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 29
- Joined: Mon Mar 30, 2015 6:00 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1193 :
in my humble opinion, for clarity....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.
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
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1193 :
Added.
thank you for your feedback!
Paul.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 29
- Joined: Mon Mar 30, 2015 6:00 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1193 :
no worries, it's a great piece of software!admin wrote:Added.
thank you for your feedback!
Paul.
Who is online
Users browsing this forum: No registered users and 8 guests