0% found this document useful (0 votes)
2 views2 pages

4 Operators in Java

The document provides an overview of operators in Java, including expressions, statements, and various types of operators such as unary, binary, ternary, relational, and logical operators. It explains the functionality of each operator type with examples. Additionally, it highlights the differences between prefix and postfix unary operators and introduces shorthand and nested ternary operators.

Uploaded by

21sonirishit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

4 Operators in Java

The document provides an overview of operators in Java, including expressions, statements, and various types of operators such as unary, binary, ternary, relational, and logical operators. It explains the functionality of each operator type with examples. Additionally, it highlights the differences between prefix and postfix unary operators and introduces shorthand and nested ternary operators.

Uploaded by

21sonirishit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: _____________________________ Grade : IX Div.

: ____________________

Roll No. : ______ Date:______________ Term : I Worksheet No: 4

Subject: Computer Applications Topic: Operators in Java

Expression
Expression is a set of variables, constants, and arithmetic operators. It is a
combination of operators and operands. Example: a * b + 8

Statement
When an expression is assigned to a variable, the complete set is referred to as
an arithmetic statement. Example: m = a * b + 8

Operators

Page 1
Unary Operator:
An operator that works on a single [Link] unary increment or decrement
operators used with a single operand will increase and decrease the value of an
operand by 1.

Prefix: When the increment or decrement operators are written before the
operand, they are termed as prefix operators. They increase or decrease the
value before the action has taken place. (++a)
Postfix: When the increment or decrement operators are written after the
operand, they are termed as postfix operators. They increase or decrease the
value after the action has taken place.(a++)

Binary Operator:
The operator that operates on two operands. Binary operators are + , - , * , / , %.
Shorthand operators are the binary operators written in short form. ( a + = 10)

Ternary Operator:
They operate on three operands. It is also called a conditional operator because
the value assigned to a variable depends upon a logical expression or a
condition.
Eg: int a = 5, b = 3; max = (a>b) ? a : b;
When a ternary operator is used within another ternary operator, it is called a
nested ternary operator.

Relational operators:
Operators that are used to show the relation among the operands.

They are > , < , <= , >= , == , !=

Logical Operators:
Operators that are used between two or more conditions in a Java statement.
They result in true or false depending upon the values in the condition.

They are AND(&&), OR(||) and NOT(!)

Page 2

You might also like