Exercise 2 Boolean operator


#1



Does anyone know how to solve this question? Thanks


Use the && operator and valid Boolean expressions on each side of &&.


Replace this line with your code.


#2

&& (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.


#3

Can you provide answer for this question? Thanks


#4

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)


#5

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

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

#6

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.


#7

how do you use boolean to fill empty comments


#8

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


#9

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