# Operators

## Operators in Java are special symbols to perform specific tasks on operands. Operators can be classified into the following types: arithmetical, relational, increment/ decrement, logical and assignment. Operations are represented byoperators. The objects of operations are referred to as operands. Operators can be unary, binary or ternary. When an integer and a floating point number are used as operands to a single arithmetic operation, the result is a floating point. The integer is implicitly converted to a floating point number before the operation takes place. Unary increment operator (+ +) increases the value of an operand by 1.Arithmetic operators are used to perform arithmetic operations, such as addition subtraction and multiplication. The arithmetic operators are of two types: unary operators and binary operators. The relational operators are used to compare two values and determine the relationship between them. The increment operator (++) adds 1 to operand’s value. The decrement operator (--) subtracts 1 from operand’s value. The logical operators are used to evaluate multiple conditions together as a single expression. The assignment operator is used to update the value of a variable. Relational operators have lower precedence than that of arithmetic operators. Logical operator ( ! ) has precedence higher than that of any of the relational or arithmetic operator.

To Access the full content, Please Purchase

• Q1

Which operator is used to compare two values, = or ==?

Marks:1

The == operator is used for comparison of two values and = is used for assignment of the values.

• Q2

Explain the following code sample:
result = someCondition ? value1 : value2;

Marks:1

This code should be read as: "If someCondition is true, assign the value of value1 to the result, otherwise assign the value of value2 to the result."

• Q3

What are operands?

Marks:1

Operands are the values and variables on which operators are applied.

• Q4

Which type of operators act upon two operands?

Marks:1

Binary operators