A very complex Boolean expression may use several logical operators like the one shown here

PHP

($x > $y) || ($x == 5) && ($x <= $z) || !($z == 1)

So, a reasonable question is “which logical operation is performed first?

The order of precedence is: logical complements (!) are performed first, logical conjunctions (&&) are performed next, and logical disjunctions (||) are performed at the end.

 Higher Precedence

Lower Precedence

Logical Operator

!

&&

||

Java, C++, C#

Visual Basic

Python

Notice: You can always use parentheses to change the default precedence.