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

Why the answer is not true?

Why the answer is not true?

andren
andren
28,558 Points

What specific question are you referring to? There are 5 questions in the quiz and they are all true or false questions so you'll have to be a bit more specific.

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

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

TRUE False Why answer is not true?

1 Answer

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

If the "answer" = 42 then it is greater than 40 and less than 50.

for an 'or' condition only one condition needs to be met for it to be true. In this case neither one is true because 42 is NOT less than 40, as well as 42 is NOT greater than 50