go to previous page   go to home page   go to next page hear noise

Answer:

No. For example, the following is also an expression:

"This is" + " a string" + " expression" 

The above expression creates a new string that is the concatenation of all the strings.


Arithmetic Operators

OperatorMeaningprecedence
- unary minushighest
+ unary plushighest
* multiplicationmiddle
/ division middle
% remainder middle
+ addition low
- subtractionlow

Arithmetic expressions are especially important. Java has many operators for arithmetic. These operators can be used on floating point numbers and on integer numbers. (However, the % operator is rarely used on floating point.) For instance, / means integer division if both operands are integers, and means floating point division if one or both operands are floating point.

An integer operation is always done with 32 bits or more. If one or both operand is 64 bits (data type long) then the operation is done with 64 bits. Otherwise the operation is done with 32 bits, even if both operands are smaller than 32 bits.

For example, with 16 bit short variables, the arithmetic is done using 32 bits:

short x = 12;        // 16 bit short
int result;          // 32 bit int

result = x / 3;      // arithmetic will be
                     // done using 32 bits

The expression   x / 3   divides a 32-bit value 12 by a 32-bit value 3 and puts the 32-bit answer in result. The literal 3 automatically represents a 32-bit value.


QUESTION 4:

Does it really matter that 12 was converted to 32 bits?