The logical operator OR, ||
This page introduces the logical operator OR.
In Java and some other languages the logical operator OR is written ||. In some places, for example some maths books, you might see the symbol $\lor$ used for the logical operator OR.
Jess wants to enroll in a course, but there are conditions for enrolment: a person can enroll if they have passed Maths 1 or if they have passed Stats 1. So Jess can enroll if
Jess has passed Maths 1 OR Jess has passed Stats 1
This tells you that:
- Jess has passed both Maths 1 and Stats 1 means that Jess can enrol.
- Jess passed Maths 1 but not Stats 1 means that Jess can enrol.
- Jess did not pass maths 1 but did pass Stats 1 means that Jess can enrol.
- Jess failed both means that Jess can't enrol.
We summarise this example in a table.
| Passed Maths 1 | Passed Stats 1 | Allowed to Enrol |
|---|---|---|
| True | True | True |
| True | False | True |
| False | True | True |
| False | False | False |
In general, || (OR) is used as shown in this truth table.
| $a$ | $b$ | $a$ OR $b$ |
|---|---|---|
| T | T | T |
| T | F | T |
| F | T | T |
| F | F | F |
Example
Find the truth value of $24\gt 50$ OR $44-44=0$.
Answer: $\underbrace{24\gt 50}_{F}$ OR $\underbrace{44-44=0}_{T}$ is F OR T, which is T. The answer is T.
Practice questions
Find the truth values of the following:
| $1+1=2$ OR $42\gt 24$ | [ ]True [ ]False |
| The capital city of Australia is Perth OR Western Sydney University is in Tasmania. | [ ]True [ ]False |
| $42\gt 24$ OR $24\gt 42$ | [ ]True [ ]False |
| $1=2$ OR $2\le 4$ | [ ]True [ ]False |
Check Answer
That's correct! You should move on to this page to continue your explorations.
Not quite. Try these questions again after reading the page above.