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

Malala Jung
Malala Jung
986 Points

Please help with this question, it doesnt make sense.

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

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

4 Answers

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Mayie,

|| is logical or operator. || combines two boolean variables or expressions and returns a result that is true if either or both of its operands are true.

So if the age is 42 the result will be false. Every age beetween 40 and 50 will result false.

No this is not true , it has to be either or so 1 condition is true than other does not matter

Malala Jung
Malala Jung
986 Points

Thank you, I got it now.

David Hinton
David Hinton
3,070 Points

Thank you Grigorij Schleifer, that also helped me

No this is not true , it has to be either or so 1 condition is true than other does not matter