Right now I am studying for the OCA Java 8 exam and yesterday I did the review questions of chapter 2 again (book OCA Oracle Certified Associate Java SE 8 Programmer I by Jeanne Boyarsky and Scott Selikoff).
While I was making these review questions I noticed something at question number 16.
I don't know if anyone else noticed this:
the question says:
what is the output of the following code snippet?
so after making the questions, I checked at the answers of chapter 2 review questions < 15 questions answered good of 20 and 5 questions wrong answered of 20.
But when I looked at the answer for question 16 I saw this:
After the first execution of the loop, i is decrememted to 9 and result to 13. But according to the book, a value is decremented by 1.
How is it then in this case that int result is decremented with 2 instead of 1?
Can somebody please help me with this?
Thank you very much for the explanation
I see now that I made a mistake in my topic.
It was number 17 of the review questions of chapter 2 and not number 16 (Sorry guys).
But coming back @ this topic.
I was wondering why the value of int Result was after decrementing changed from 15 to 13?
Is it because there are two variable at the same line (int result, i)?
Or is their another reason why the value of int result changed from 15 to 13 after decremented?