Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1335 :

Posted: Wed Dec 12, 2012 11:31 am
by ETS User
for k = 4, the explanations says that after after taking control to case 4:, all the statements till the end will be executed and j will be incremented 3 times:

case 4: j++
case 5: j++
default: j++

I don't understand why j would be incremented for case 5: since k!=5

Shouldn't j be incremented only twice for:
case 4:j++
default: j++

in this case the answer should be j + k = 7?

Re: About Question enthuware.ocajp.i.v7.2.1335 :

Posted: Wed Dec 12, 2012 12:10 pm
by admin
It is true that k !=5, but that doesn't matter because there is no break in the case blocks that appear before case 5. So the control falls through.

This is an important concept. So please check this out.

HTH,
Paul.