# OCA Java SE 8 Programmer I Study Guide - Chapter 2 - Review Question Confusion

posted 1 week ago

Hi!

Today I would like to bring up a question I am confused about in the OCA Java SE 8 Programmer I Study Guide by Jeanne Boyarsky and Scott Selikoff. In the Chapter 2 Review Questions, I found #1 a little confusing.

1. Which of the following Java operators can be used with boolean variables? (Choose all that apply)

I chose A, D, and F. However, the answer was supposed to be A and D. But <= is very alike == so why is answer F wrong?

Thanks,

Maxwell

Today I would like to bring up a question I am confused about in the OCA Java SE 8 Programmer I Study Guide by Jeanne Boyarsky and Scott Selikoff. In the Chapter 2 Review Questions, I found #1 a little confusing.

**Question:**1. Which of the following Java operators can be used with boolean variables? (Choose all that apply)

**A.**==**B.**+**C.**--**D.**!**E.**%**F.**<=I chose A, D, and F. However, the answer was supposed to be A and D. But <= is very alike == so why is answer F wrong?

Thanks,

Maxwell

posted 1 week ago

x <= y is like a shorthand for x < y && x == y.

Let's think about this in English. The number 4 is clearly less than (or equal to) the number 5. The number 5 is also (less than or) equal to the number 5. So <= works.

What would it mean for false to be less than than true? It wouldn't. So Java doesn't allow comparing booleans with <= because they can;t be substituted for x and y above.

Let's think about this in English. The number 4 is clearly less than (or equal to) the number 5. The number 5 is also (less than or) equal to the number 5. So <= works.

What would it mean for false to be less than than true? It wouldn't. So Java doesn't allow comparing booleans with <= because they can;t be substituted for x and y above.

[OCA 8 book] [OCP 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]

Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2

posted 1 week ago

I think It should be x <= y is like a shorthand for x < y || x == y. Because it is x less than (or equal to) y but not x less than (and equal to) y .

Please correct me I am wrong.

x <= y is like a shorthand for x < y && x == y.

I think It should be x <= y is like a shorthand for x < y || x == y. Because it is x less than (or equal to) y but not x less than (and equal to) y .

Please correct me I am wrong.

Whizlabs Support (info@whizlabs.com or +91-9740134466)

OCAJP 8 Free Questions | OCPJP 8 Free Questions |OCEJWCD | OCMJEA

posted 1 week ago

Narayana,

Yeah, I meant that . Thanks for pointing it out.

What I posted would always evaluate to false.

Yeah, I meant that . Thanks for pointing it out.

What I posted would always evaluate to false.

Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2