About Question enthuware.ocajp.i.v8.2.1408 :

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

Moderator: admin

Post Reply
Elvira Sharipova
Posts: 1
Joined: Sun Feb 13, 2022 12:55 pm
Contact:

About Question enthuware.ocajp.i.v8.2.1408 :

Post by Elvira Sharipova »

Hello! The explanation states that "Comparison operators have lower precedence than mathematical operators."
But what if we have something like this:
int x1 = 50, x2 = 75;
boolean b = x1 >=x2;
Is it equal to boolean (b = x1) >=x2; or to boolean b = (x1 >=x2);?
What will be evaluated first: the comparison or assigning x1 value to b?

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

Re: About Question enthuware.ocajp.i.v8.2.1408 :

Post by admin »

= is not a mathematical operator, so, why do you think it can be boolean (b = x1) >=x2; ?

= is an assignment operator and has the lowest precedence out of all (except lambda).

You may want to go through this article to understand the basics of expression evaluation:
https://enthuware.com/oca-ocp-java-cert ... evaluation
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot], marpiva and 38 guests