About Question com.enthuware.ets.scjp.v6.2.509 :

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

Moderator: admin

Post Reply
ETS User

About Question com.enthuware.ets.scjp.v6.2.509 :

Post by ETS User »

Not sure what is meant by "...implicit narrowing is permitted only among byte, char, short, and int."

Assigning an int to a short requires a cast.

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

Re: About Question com.enthuware.ets.scjp.v6.2.509 :

Post by admin »

Hi,
Implicit narrowing happens only for constants. A cast is not required for says byte b = 10; even though 10 is an int.

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

asi-aal
Posts: 10
Joined: Wed Nov 23, 2022 3:40 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.509 :

Post by asi-aal »

Are we supposed to know that 43e1 produces a double and 0x0123 produces a float?

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

Re: About Question com.enthuware.ets.scjp.v6.2.509 :

Post by admin »

You do need to know the ways in which you can write a double value (such as 1.0 or 43e1 ) and the ways in which you can write an integral value (such as 1 or 0x0123 ). You also need to know that an integer value can be assigned to a float variable without a cast.
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 44 guests