About Question com.enthuware.ets.scjp.v6.2.701 :

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

Moderator: admin

Post Reply
devlam
Posts: 50
Joined: Sun Nov 10, 2013 4:39 am
Contact:

About Question com.enthuware.ets.scjp.v6.2.701 :

Post by devlam »

When answering this question I was in doubt:
will b2 = b1 first be evaluated and then the rest of the expression which then become b2 != b2,
or will b1 != b2 first be evaluated putting the result in b2.
With b1 and b2 both being false the result is the same, but if b1 had been true initially it would have been different.
I answered correct but don't know the real rule with such expressions. Can you provide that?

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

Re: About Question com.enthuware.ets.scjp.v6.2.701 :

Post by admin »

Details of evaluation order are given here: http://docs.oracle.com/javase/specs/jls ... l#jls-15.7
and http://docs.oracle.com/javase/specs/jls ... ls-15.26.1

So you should group the given expression like this: b2 = (b1 != b2) rather than (b2 = b1) != b2

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests