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

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

Moderator: admin

Post Reply
atheedom
Posts: 2
Joined: Sat Apr 21, 2012 12:05 pm
Contact:

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

Post by atheedom »

The answer to question 726 says "& can have integral as well as Boolean operands". I don't understand how this can be true. Would you show me an example. Thanks.

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

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

Post by admin »

Example for boolean operands:

Code: Select all

boolean b1 = true;
boolean b2 = true;
boolean b = b1 & b2;
if(b){
   System.out.println("hello");      
}
Example for integral operands:

Code: Select all

  int i1 = 10;
 char c = 'a';
 int k =  i1 & c;
 System.out.println(k);      
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Val Martinez
Posts: 11
Joined: Thu Sep 01, 2022 10:58 am
Contact:

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

Post by Val Martinez »

The explanation

"^ is bitwise xor operator that performs an "xor" (aka exclusive or, in which, the result is 1 only if exactly one of the two operands is 1)"

is not correct.

XOR returns 1 if the bits compared are differents and 0 if are the same.

For example:

int y = 3;//11
int x = 3;//11
int z = y^x;
System.out.println(z);//prints 0

Please, fix it. Thank you.

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

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

Post by admin »

The explanation is correct. You are also saying the same thing but in different words. When you have exactly one of two digits as 1, then, obviously, the two digits will be different.
If you like our products and services, please help us by posting your review here.

cristibctr
Posts: 6
Joined: Sun Jun 18, 2023 11:03 am
Contact:

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

Post by cristibctr »

I'm not saying it's wrong but I genuinely thought the '& can have integral as well as boolean operands.' answer was refering to the calculus 'Integral' and trying to check if the reader is paying close attention to the answers so I didn't choose it. Could it please be changed to integer as that's what the java type is called?

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

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

Post by admin »

This is official terminology as used by the Java Language Specification. See attached screen shot please.
test.png
test.png (103.66 KiB) Viewed 1935 times
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 41 guests