• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Sybex OCP11-Complete - Chapter-3 - Increment and Decrement Operators - Lion and Tiger - Kindle

 
Ranch Foreman
Posts: 68
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I created a new post because this is on a different book, the complete version. I'm new here and not familiar with the regulation. If this is not allowed, I will delete it.

This problem has been discussed in another post, and according to Campbell Ritchie's reply and tests, the 1z0-815 version, which reads "First, lion is incremented", is correct.

Campbell Ritchie wrote:Yes, as we concluded earlier, the original explanation in the book appears to be correct.


That is to say, in code ++lion should be evaluated before lion-- because of order of evaluation.

However, it looks like the author misunderstood Campbell Ritchie and put it into errata again.

Jeanne Boyarsky wrote:And back to errata.


And now, it is still in the errata of 1z0-815, and to the contrary, the complete study guide reads "First, lion is decremented."

I can tell, only one of the two versions is correct, right? In my own opinion, the original one is correct.




 
Marshal
Posts: 70234
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Not got the time or energy to go through this problem in detail, but it appears from the older discussion you quoted that the older versions of the book had the correct explanation but not the later edition. I think my example starting −1 shows that the ++ is executed first. If the -- were executed first, the code wouldn't throw an exception.
 
Frank Mi
Ranch Foreman
Posts: 68
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. ^_^

Yes, long story short, the 1z0-815 book might be correct (the same as what you said), but it was put into errata incorrectly, then affect the new complete version.
 
Campbell Ritchie
Marshal
Posts: 70234
282
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again to cut a long story short, whichever version says ++ is executed first is correct.
 
Frank Mi
Ranch Foreman
Posts: 68
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, thanks. I don't know how to @ person in this forum, could you tell me how to inform the authors to put it onto errata?
 
Campbell Ritchie
Marshal
Posts: 70234
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please wait; one of the authors checks this forum regularly.
 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've added it back to the errata. Scott and I discussed it and we want to get rid of this example. it's too complicated for the exam. It's also too complicated to explain/understand to be useful.
 
Frank Mi
Ranch Foreman
Posts: 68
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne and Scott,

Thank you for your reply. Though I don't agree that it is too complicated, actually it is common and in scope of the exam. So please modify but don't get rid of the example.

According to JLS §15.7.1:

JLS §15.7.1 wrote:The left-hand operand of a binary operator appears to be fully evaluated before any part of the right-hand operand is evaluated.


So that,
is the same as:

Other than that, I've seen several java mock exam questions like the following one:

These questions are fine and should be understood by us.

Do you think what I said make sense?
 
Jeanne Boyarsky
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank,
The number of people who found it confusing suggests it isn't furthering our goals here . I'm glad you understand it though!
 
Frank Mi
Ranch Foreman
Posts: 68
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

Sorry for bothering you again. But the information in the Errata (both the 1z0-815 and the complete version) is still incorrect. It should be "++lion should execute before lion–",  rather than after.
 
Jeanne Boyarsky
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Frank Mi wrote:Hi Jeanne,

Sorry for bothering you again. But the information in the Errata (both the 1z0-815 and the complete version) is still incorrect. It should be "++lion should execute before lion–",  rather than after.


Yup. Thank you
    Bookmark Topic Watch Topic
  • New Topic