Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Perfecting the Prototype Censoring Words - Using Logical ORs

Jason Hart
Jason Hart
1,089 Points

Quiz Question - Bob's Three Kids

For the "Using Logical ORs and ANDs" quiz, one of the questions is:

If Bob is 50, has 3 children, and works for a software company, what is the answer to this logical statement: age > 30 || children < 3 || isEmployed

The answer the quiz is looking for is True.

I thought it would be False as the number of his children (3) is equal to, not less than 3.

In Java, do you have to specify "less than or equal to" or does < account for that?

Thanks!

If Bob is 50, has 3 children, and works for a software company, what is the answer to this logical statement: age > 30 || children < 3 || isEmployed

The answer the quiz is looking for is True.

its clearly False but when i click False my answer is incorrect.

Jason Hart
Jason Hart
1,089 Points

Hi Jahangir. I too did not get this question at first. What I was missing is that || is OR. I was reading the question as "Is Bob over 30 years old AND has less than 3 children AND is employed." I answered False because Bob has 3 children not less than 3 children.

But II is OR so the question really is: Is Bob over 30 years old OR has less than 3 children OR is employed.

If Bob meets anyone one of those three, then the statement is True.

2 Answers

Dan Johnson
Dan Johnson
40,533 Points

In Java you use <= to specify less than or equal to. The result is true since only one condition has to be true for the entire expression to be true when using logical OR.

Jason Hart
Jason Hart
1,089 Points

Ah! That's what I missed. Makes sense. Thanks.

Nice! I was like whaaaat!?? at 1st too lol

"If Bob is 50, has 3 children, and works for a software company, what is the answer to this logical statement." This statement is misleading. For the result to be true, all three conditions have to be true. I know the code is using Or (||) but the statement does not match the code. It should be like "If Bob is 50, has 3 children, or works for a software company, what is the answer to this logical statement." In this case, only one of the condition need to be met.