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

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.1227 :

Post by ETS User »

Hi,

option 3 (It will print 4, 3 when line 1 is replaced by continue.) is a correct option but I figure it would print '4, 4' - could you explain why please?

Also, I think there's a typo in the explanation about the break statement, at step 2.3 'm' suddenly jumps to 2, then increments to 3, but still prints out 2. Should it not be m=1 at step 2.3, then m=2 at step 3.3?

Thanks in advance for your help:)

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

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

Post by admin »

Yes, you are right. m should be 1 in iteration 1. This has now been fixed. Rest is fine.

Regarding continue:

1. k=0, m=0

2. iteration 1: i=0
2.1 k = 1
2.2 i == 2 is false
2.3 m = 1

3. iteration 2: i = 1
3.1 k=2
3.2 i==2 is false
3.3 m = 2

4. iteration 3: i = 2
4.1 k=3
4.2 i==2 is true
4.3 continue - This means rest of the statements in the loop for this iteration will be skipped and thus m will not be incremented and will remain 2.

5. iteration 4: i = 3
5.1 k=4
5.2 i==2 is false
5.3 m = 3

6. print 4, 3

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Guest

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

Post by Guest »

not that this question is hard by any means but it's very time consuming to try out, my question is are we allowed pen and paper in the exam room? or something they give us to use?

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

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

Post by admin »

Yes, you are allowed pen and paper.
You may get questions that involve simple loops where you have to work through each iteration.
If you like our products and services, please help us by posting your review here.

Guest

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

Post by Guest »

admin wrote:Yes, you are allowed pen and paper.
You may get questions that involve simple loops where you have to work through each iteration.
that's fine, as long as i have a pen and paper because my heap seems not to function correctly sometimes :ugeek: !!

Thanks.

Chandni
Posts: 6
Joined: Thu May 08, 2014 12:13 pm
Contact:

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

Post by Chandni »

The break statement, if inserted in line 1 will break the 'if' loop or the 'for' loop?

Thanks in adv.

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

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

Post by admin »

break will apply to the for loop. if is not a loop.
Please try it out.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Chandni
Posts: 6
Joined: Thu May 08, 2014 12:13 pm
Contact:

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

Post by Chandni »

admin wrote:break will apply to the for loop. if is not a loop.
Please try it out.

HTH,
Paul.
Thanks alot.

Post Reply

Who is online

Users browsing this forum: No registered users and 96 guests