About Question enthuware.ocajp.i.v7.2.1196 :

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

Moderator: admin

Post Reply
TheSarjo
Posts: 15
Joined: Fri Jul 12, 2013 12:34 pm
Contact:

About Question enthuware.ocajp.i.v7.2.1196 :

Post by TheSarjo »

Hello!
in explanation of this exercise, there is this statement:
2. The switch variable must be big enough to hold all the case constants.
So, if switch variable is of type char, the no case constant can be greater than 65535 because char's range is from 0 to 65535.
I don't understand what is a "no case constant".
Could someone do an example?
Sorry if the question is probably dumb.
Thank you very much!

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

Re: About Question enthuware.ocajp.i.v7.2.1196 :

Post by admin »

It is a typo, it should say, "...theN no case constant...". Here is an example:

Code: Select all

switch(x){

case 10: ...
case 20: ...

}
10 and 20 are the constants mentioned above. You cannot have variables here.
If x is declared of type byte, then you cannot have case 255: because 255 is too big for a byte.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

TheSarjo
Posts: 15
Joined: Fri Jul 12, 2013 12:34 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1196 :

Post by TheSarjo »

Ahhhh :-) :oops:
sorry, for a moment i was lost..
thank you!

gparLondon
Posts: 63
Joined: Fri Oct 31, 2014 6:31 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1196 :

Post by gparLondon »

Now, do we have to remember the range of all primitive type for the exam?

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

Re: About Question enthuware.ocajp.i.v7.2.1196 :

Post by admin »

Not for all but at least for byte.
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 211 guests