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 Using Logical ORs and ANDs

can someone please explane this question? dosen't he meet all the requirements?

Assuming age is set to 42, what is the value stored in the boolean answer:

boolean answer = (age < 40 || age > 50);

1 Answer

Brandon Khan
Brandon Khan
21,619 Points

A boolean can be true or false. The question is asking you what this will evaluate to. When using the || ( or ) operator true will be evaluated if the conditions meet any of the requirements on its left or right. The code here is asking you "is the age 42 less than 40 or is the age 42 greater than 50? " if 1 of the statements is true it will return true. if both are false it will return false.