The following examples illustrate assignment of primitive values:

**
**

The **unary operators** have the highest precedence of all the arithmetic operators. The **unary operator** - negates the numeric value of its
operand. The following example illustrates the function of unary operators:

**int value = - -10; // (-(-10)) is 10**

Notice the blank needed to separate the unary operators; otherwise, these would be interpreted as the decrement operator -- . The unary operator + has no effect on the evaluation of the operand value.

__Multiplicative Binary Operators: *, /, %__

__Multiplication Operator: __* .

Multiplication operator * multiplies two numbers.

int sameSigns = -4 * -8; // result: 32

double oppositeSigns = 4.0 * -8.0; // result: -32.0

int zero = 0 * -0; // result: 0

__Division Operator / -:__

Integer division always returns the quotient as an integer value, i.e. the result is truncated toward zero. Note that the **division **performed is **integer division** if the operands have integral values, even if the result will be stored in a **floating-point **type.An ArithmeticException is thrown when attempting integer** division with zero**, meaning that integer division by zero is an illegal operation.
If any of the operands is a **floating-point type**, the operation performs** floating-point division**.

**Examples:-**

int var1 = 4 / 5; // result: 0

int var2= 8 / 8; // result: 1

double dvar = 12 / 8; // result: 1 by integer division. d1 gets the value 1.0.

__Remainder Operator:__ %

In mathematics, when we** divide **a number (**the dividend**) by a another number (**the divisor**), the result can be expressed in terms of a
**quotient** and a **remainder**. For example, dividing 7 by 5, the quotient is **1** and the remainder is **2**. The **remainder operator % **returns the
remainder of the division performed on the operands.

__Example__:-

int quotient = 7 / 5; // Integer division operation: 1

int remainder = 7 % 5; // Integer remainder operation: 2

**Additive Binary Operators: +, -**

The addition operator **+** and the subtraction operator - behave as their names imply: add or subtract values. The binary operator **+ **also
acts as string concatenation if any of the operands is a string .
Additive operators have lower precedence than all the other **arithmetic operators**.

int var1=10, var2 =10;

int var3=**var1+ var2** //result will be 20

__Boolean Logical Operators: !, ^, &, |__

**Boolean logical operators** include the unary operator ! (logical complement) and the binary operators & (logical AND), | (logical inclusive
OR), and ^ (logical exclusive OR, a.k.a. logical XOR). **Boolean logical operators **can be applied to boolean operands, returning a boolean
value. The operators &, |, and ^ can also be applied to integral operands to perform **bitwise logical operations** .
Given that x and y represent boolean expressions.

**Logical complement !**x** ** Returns the complement of the truth-value of x.

**Logical AND** x **&** y Returnstrue if both operands are true; otherwise, **false**.

**Logical OR** x **| **y true if either or both operands are **true;** otherwise,**false.**

**Logical XOR** x ^ y true if and only if one operand is **true**; otherwise, **false**.

These operators always evaluate both the operands, unlike their counterpart conditional operators && and || .

__Examples:-__

**boolean** b1, b2, b3 = **false**, b4 = false;

b1 = 4 == 2 & 1 < 4; // false, evaluated as (b1 = ((4 == 2) & (1 < 4)))

b2 = b1 | !(2.5 >= 8); // true

b3 = b3 ^ b2; // true

b4 = b4 | b1 & b2; // false

Order of evaluation is illustrated for the last example:-

**(b4 = (b4 | (b1 & b2)))**

(b4 = (false | (b1 & b2)))

(b4 = (false | (false & b2)))

(b4 = (false | (false & true)))

(b4 = (false | false))

(b4 = false)

__Relational Operators: <, <=, >, >=__

**a < b** |
a less than b? |

**a <= b** |
a less than or equal to b? |

**a > b** |
a greater than b? |

**a >= b** |
a greater than or equal to b? |

All relational operators are binary operators, and their operands are numeric expressions.The evaluation results in a boolean value. Relational operators have precedence lower than arithmetic
operators, but higher than that of the assignment operators.

__Examples:-__

double hours = 45.5;

**boolean** overtime = **hours >= 35.0;** // true.

boolean order = **'A' < 'a';** // true. Binary numeric promotion applied.

__Conditional Operators: &&, ||__

Conditional operators **&& **and **||** are similar to their counterpart logical operators & and** |** , except that their evaluation is short-circuited.
Given that x and y represent values of boolean expressions, the conditional operators are given below.

Conditional AND :- ** x && y** true if **both operands **are **true**; otherwise, false.

Conditional OR:- ** x || y** true if **either or both operands** are **true**; else false.

**Examples:-**

boolean b1 = 4 == 2 && 1 < 4; // false, short-circuit evaluated as

//(b1 = ((4 == 2) && (1 < 4)))

boolean b2 = !b1 || 2.5 > 8; // true, short-circuit evaluated as

// (b2 = ((!b1) || (2.5 > 8)))

boolean b3 = !(b1 && b2); // true

boolean b4 = b1 || !b3 && b2; // false, short-circuit evaluated as

// (b4 = (b1 || ((!b3) && b2)))