[HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]

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

Moderator: admin

Post Reply
flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

[HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]

Post by flex567 »

Does numeric promotion applies to wrappers as well?

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

Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]

Post by admin »

Good question. Yes, it does. So, the following will not compile -
Byte b1 = 10;
Byte b2 = -b1;
The book should have mentioned this. Will get it updated.
thank you for your feedback,
Paul.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]

Post by flex567 »

When will be the book updated? I am using Kindle version, will I receive the update?

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

Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]

Post by admin »

We update the version after a few errors are reported. There is no fixed schedule.
Regarding Kindle, I think Amazon delivers the updated version automatically to existing customers but I am not sure about when they do it.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]

Post by flex567 »

2. Binary numeric promotion - Both the operands of a binary operator are promoted to an int but if any of the operands is larger than an int, the other operand is promoted to the same type as the type of the larger one. Thus, for example, if both the operands are of type byte,
then both are promoted to int but if any of the operands is a long, float, or double, the other one is also promoted to long, float, or double, respectively.
It is not mentioned what happens in case one operand is double and the other is long ??

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

Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]

Post by admin »

It says, "if any of the operands is larger than an int, the other operand is promoted to the same type as the type of the larger one" and then, "For example, if any of the operands is a long, float, or double, the other one is also promoted to long, float, or double, respectively".
So, between long and double, double is larger, so long will be promoted to double.
Should be improved for clarity.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

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