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

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?

Online
Posts: 8703
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

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.

Guest

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

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?

Online
Posts: 8703
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Yes, you are allowed pen and paper.
You may get questions that involve simple loops where you have to work through each iteration.

Guest

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

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 !!

Thanks.

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

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

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

Online
Posts: 8703
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

break will apply to the for loop. if is not a loop.

HTH,
Paul.

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

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

admin wrote:break will apply to the for loop. if is not a loop.