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

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

Moderator: admin

Post Reply
Daniel Clinton
Posts: 29
Joined: Fri Aug 08, 2014 11:22 am
Contact:

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

Post by Daniel Clinton »

Hi Paul,
Just a tiny but hopefully :) useful thought I had about the question.

As it stands, both logical && and bitwise & will produce the same result.
If i++ were tested for equality with an int other than 0
it would bring the second concept in the explanation into play.

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

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

Post by admin »

Daniel Clinton wrote:Hi Paul,
Just a tiny but hopefully :) useful thought I had about the question.

As it stands, both logical && and bitwise & will produce the same result.
In this particular case, yes.
If i++ were tested for equality with an int other than 0
it would bring the second concept in the explanation into play.
Not sure what you mean. Can you write it in code so that it is clear what you mean?
-Paul.

Daniel Clinton
Posts: 29
Joined: Fri Aug 08, 2014 11:22 am
Contact:

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

Post by Daniel Clinton »

Hmmm, I'm splitting hairs really and my confidence in the idea is waning but...
my thought was to try to add something the question by having the first expression evaluate as false like:

Code: Select all

		int i = 0;
		int j = 1;
		if ((i++ == 1) & (j++ == 2)) {
			i = 12;
		}
(to test if the answerer spots the single & operator)

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

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

Post by admin »

You got it right. That would make the question tougher. I think that is covered in some other question though. Not every question needs to hit all the gotchas :)

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests