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

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

Moderator: admin

Post Reply
danielfb
Posts: 1
Joined: Tue Dec 01, 2015 5:07 pm
Contact:

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

Post by danielfb »

In

Code: Select all

boolean b1 = false;
boolean b2  = false; 
if (b2 = b1 != b2)
Why is, according to your answer, "b1 != b2" evaluated before the "b2 = b1"?
Is this because of the != having a higher precedence?

Thanks,
Dani.

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

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

Post by admin »

Yes, assignment operator has the least precedence.
If you like our products and services, please help us by posting your review here.

Deleted User 3513

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

Post by Deleted User 3513 »

Just wanted to clarify again, in the line if(b2=b1!=b2), first it evaluates b1!=b2 which returns false and then it is assigned to b2. Here b2 is evaluated in the if-condition which has the value of false and that results to the execution of the else block?

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

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

Post by admin »

That is correct.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests