Operators Flashcards

1
Q

Operators

A

• Operators are tokens that carry out specific
operations on data.
• The data could be a variable or a constant or
a literal or an expression and it is known as
an Operand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Classification of operators based on number of operands

A
  • Unary - act on one operands
  • Binary - act on two operands
  • Ternary - act on three operands
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Classification of operators based on operations

A
• Based on the type of operations they
perform, they are classified as[CARLA]:
- Conditional operators
- Arithmetic operators
- Relational operators
- Logical operators
- Assignment operators
– Shift operators (not included in syllabus)
– Bit-wise operators (not included in syllabus)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Precedence of operators

A

• This determines the order in which the
expressions are evaluated. Java uses BODMAS
and Associativity rules to evaluate an expression.
The order of evaluation is as follows:
1. Expression with Parenthesis
2. Prefix Operators (Increment ++, Decrement –)
3. Arithmetic operators
4. Relational operators
5. Logical Operators
6. Assignment Operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Operator Associativity

A

• When more than one operation in an expression has the same precedence, then the associativity rules determine the order of the operations. Associativity rules determine the grouping of operands and operators in an expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Modulus operator

A

It is used for finding the remainder in a division operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Plus operator

A
  • Adding literals, variables, constants or expressions of numeric data types
  • Concatenating strings
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Unary minus

A

It negates an arithmetic operand’s value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Division operator

A
  • Returns the quotient created by the integer division of a whole number when it’s operands are of integral data types.
  • Returns the quotient created by the division of its operands when one of its operands are of fractional data types.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Relational operators

A

Relational operators are used for comparing two different operands. The operands can be variables, literals or arithmetic expressions. If the comparison is true, it results into the boolean value true and if the comparison is false it results into the Boolean value false.

They do not work with Strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Logical operators

A

These operators are used for forming more complex
expressions. They are used for combining two relational
expressions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Equals operator

A

• = is used for assigning a literal or a variable or the result of an expression to a variable on the left hand side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Presedence of logical operators

A

! -> && -> ||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly