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

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:

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

Post by flex567 »

What is implicit narowing?

I would assume that it is:
assign a larger type value to a variable of smaller type without programmer doing it?

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

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

Post by admin »

This discussion should be helpful: https://stackoverflow.com/questions/278 ... es-in-java

But yes, "narrowing" is when a larger type (such as int) (or in case reference types, a super type) is assigned to a variable of of a smaller type (such as byte) (or in case of reference types, a sub type) and "implicit" means without using an explicit cast. Narrowing can therefore happen for primitives as well as for reference types. But implicit narrowing happens only in the case of primitives and only during assignment of constant expressions.
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: About Question enthuware.ocajp.i.v8.2.1247 :

Post by flex567 »

Is there a way to create a short literal?

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

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

Post by admin »

No, and not a byte literal either.
If you like our products and services, please help us by posting your review here.

crazymind
Posts: 85
Joined: Mon Dec 24, 2018 6:24 pm
Contact:

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

Post by crazymind »

Hi, Does OCA require to remember the widening or narrowing conversion? Is there an easy way to remember it? Thanks

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

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

Post by admin »

Yes, you need to know this for the exam. There are only a few simple rules that govern it. You will have to memorize these rules. I am not aware of any other way.
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], Google [Bot] and 46 guests