Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817
Moderator: admin
mikolajczak4
Posts: 3 Joined: Sat Feb 20, 2021 4:48 am
Contact:
Post
by mikolajczak4 » Tue Feb 23, 2021 2:17 pm
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: 10055 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Tue Feb 23, 2021 6:05 pm
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 .
cjgiron
Posts: 14 Joined: Fri Sep 09, 2022 5:03 pm
Contact:
Post
by cjgiron » Mon Sep 19, 2022 7:00 pm
Hello Admin,
Will the actual test expect us to know how to parse numbers with the radix parameter?
admin
Site Admin
Posts: 10055 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Tue Sep 20, 2022 9:43 pm
You will not need to convert or parse values but you may see a question that requires you to know that such a method exists.
If you like our products and services, please help us by posting your
review here .
Users browsing this forum: No registered users and 43 guests