The type of an expression is always identical to the data type of the result value. There are three types of expression, corresponding to the three data types:
arithmetic expressions
logical or Boolean expressions
string expressions
The type of a simple expression is determined by the operator that links together the base terms. The table below lists simple expressions and their components:
Type | Operators | Base terms | Result data type |
Arithmetic expression | Arithmetic | Numbers | Integer |
Relational expression | Relational | Numbers | Boolean |
Logical or Boolean | Logical | Boolean constants | Boolean |
String expression | Concatenation | String literals | String |
For complex expressions, the data type of the result, and thus of the expression, is determined by the last operator to be evaluated. The order of precedence for operators and the way in which expressions are evaluated is described in the next section.