About Question enthuware.ocpjp.v11.2.3140 :

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

Moderator: admin

Post Reply
mikolajczak4
Posts: 3
Joined: Sat Feb 20, 2021 4:48 am
Contact:

About Question enthuware.ocpjp.v11.2.3140 :

Post by mikolajczak4 »

Hi,

I have one doubt in that answer.

Code: Select all

Double dVal = 0.0;
if((dVal = Double.parseDouble(str)) == iVal){ //2
== has precedence over = so the result of Double.parseDouble(str)) == iVal is boolean and it is assigned to dVal which is Double.

Do I miss something here ?

Thanks,
Wojciech

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

Re: About Question enthuware.ocpjp.v11.2.3140 :

Post by admin »

But there are parentheses involved. The expression dVal = Double.parseDouble(str) is surrounded by ( ). So, it has to be evaluated first. Operator precedence would have come into picture to resolve the ambiguity if all the terms of an expression were at the same level i.e.

dVal = Double.parseDouble(str) == iVal
If you like our products and services, please help us by posting your review here.

mikolajczak4
Posts: 3
Joined: Sat Feb 20, 2021 4:48 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.3140 :

Post by mikolajczak4 »

my bad, thank you !

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests