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?
About Question enthuware.ocajp.i.v7.2.1335 :
Moderator: admin
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1335 :
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.
This is an important concept. So please check this out.
HTH,
Paul.
Who is online
Users browsing this forum: No registered users and 4 guests