The logical operator AND, &&

Simple conditions or expressions can be combined using operators AND, OR and NOT to create more complicated expressions. This page introduces the operator AND.

In Java and some other languages the logical operator AND is written &&.

Imagine that you are at an airport and want to board a flight. you might be told that the condition for being allowed to board the flight is that

you have your passport AND you have a ticket.

This tells you that

  • You will be able to board if you have both those items.
  • If you don't have your passport but do have a ticket you will not be able to board.
  • If you don't have a ticket but do have your passport you will not be able to board.
  • If you have neither item you will not be able to board.

We summarise this example in a table.

You have your passport You have a ticket You may board
True True True
True False False
False True False
False False False

This table is called a truth table. The truth table gives the truth value if $a$ AND $b$, that is $a$&&$b$, for all possible truth values of pairs of statements $a$ and $b$.

$a$$b$$a$&&$b$
True True True
True False False
False True False
False False False

The truth table defines the use of && (AND).

In some places, for example some maths books, you might see the symbol $\land$ used for the logical operator AND.

Examples

Find the truth value of $24\gt 50\&\&44-44=0$.

Answer: Firstly, $24\gt 50$ is F, $44-44=0$ is T. We have $\underbrace{24\gt 50}_{F}\&\&\underbrace{44-44=0}_{T}$.

As F&&T is F, the answer is F.

Find the truth value of $50\gt 24$ AND $44-44=0$.

Answer: Both $50\gt 24$ and $44-44=0$ are T. We have $\underbrace{50\gt 24}_{T}$&&$\underbrace{44-44=0}_{T}$.

As T AND T is T, the answer is T.

Practice questions for AND

Here are some more practice questions for you. Find the truth value of each statement (that is, decide whether each is true or false). Click on the "Check Answers" button to see if you are correct.

$1+1=2$&&$42\gt 24$
The capital city of Australia is Perth AND Western Sydney University is in Tasmania.
$42\gt 24$ AND $24\gt 42$
$1=2$&&$2\le 4$