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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ETS User

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

Post 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?

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests