Exercise 2 Boolean operator


Does anyone know how to solve this question? Thanks
<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
Use the && operator and valid Boolean expressions on each side of &&.


Replace this line with your code.

<do not remove the three backticks above>

&& (Logical and) is a binary operator AND, It means that It takes two data (Boolean values) to operate on.

This is how it works.

true && true -- > true
true && false --> false
false && false --> false
false && true --> false

so It evaluates true if both expressions(left and right sides evaluates to true) otherwise it gives us false.

AS we’ve already know how to use comparison operators ,use them and make boolean expressions then use &&.

one simple boolean expression should look like this…

int x = 3;
int y = 4;

x > y will evaluate to a boolean value.

1 Like

Can you provide answer for this question? Thanks

I can’t ( It’s against rules of CC) ,also It won’t help you in long run!

Tho I can give you further hint.

look, this is what you have to make…

booleanExpression && booleanExpression

Now all you have to do is to create two boolean expressions or you can directly use boolean values (true/false)

I think it’s right as follow, thanks a lot!!!

boolean p=true;
boolean j=false;
System.out.println(p && j);

Yeah thats how we use && with boolean expressions/values.
While you go with CC’s exercises, do read some side tutorials on Java.
lots of cool tutorials are available on the internet.

how do you use boolean to fill empty comments

Hey @brady38,
Can you put it more clearly,? any code or exercise link?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.