Java Java Basics Perfecting the Prototype Using Logical ORs and ANDs

Kendhall Lebron Ruiz
Kendhall Lebron Ruiz
Pro Student 1,143 Points

Boolean question

Assuming that Sara has taken the Java and Python tracks, what is the value of isFamiliar below:

boolean isFamiliar = (
learnedJava || 
learnedPython ||
learnedRuby) ; 

Why is the answer true instead of false? Because she is familiar with Java AND Python.

[MOD: edited code block - srh]

1 Answer

Steve Hunter
Steve Hunter
Treehouse Moderator 57,564 Points

Hi there,

For an OR condition, you just need one true condition within the comparators to make the entire result true. An AND comparator would require all conditions to be true.

Make sense?


true || true == true
false || true == true
true || false == true
false || false == false