0% found this document useful (0 votes)
12 views

Java PM3

This document provides an introduction to various Java operators including: - Escape sequences like \" and \n for formatting text output - Arithmetic operators like +, -, *, /, and % for mathematical calculations - Relational operators like ==, !=, >, <, >=, <= for comparisons - Logical operators like &&, ||, ! for conditional logic - Assignment operators like =, +=, -= for assigning values - Increment/decrement operators like ++, -- for modifying values - Bitwise operators for bit-level manipulation of numeric data It also discusses operator precedence and ternary operators.

Uploaded by

Malay Shah
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)
12 views

Java PM3

This document provides an introduction to various Java operators including: - Escape sequences like \" and \n for formatting text output - Arithmetic operators like +, -, *, /, and % for mathematical calculations - Relational operators like ==, !=, >, <, >=, <= for comparisons - Logical operators like &&, ||, ! for conditional logic - Assignment operators like =, +=, -= for assigning values - Increment/decrement operators like ++, -- for modifying values - Bitwise operators for bit-level manipulation of numeric data It also discusses operator precedence and ternary operators.

Uploaded by

Malay Shah
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
You are on page 1/ 12

Object Oriented Programming

with Java (MTCA13104)


Unit 1: Introduction To Java
Java Data Type
Escape Sequences
▪ Escape sequences in general are used to signal an alternative interpretation
of a series of characters.
▪ For example, if you want to put quotes within quotes you must use the
escape sequence, \", on the interior quotes.
System.out.println("Good Morning \"World\"");

Escape Sequence Description


\’ Single quote
\” Double quote
\\ Backslash
\r Carriage return
\n New Line
\t Tab
Operators
Arithmetic Operators
Operator Name Description Example
+ Addition Adds together two values x+y

- Subtraction Subtracts one value from another x-y

* Multiplication Multiplies two values x*y

/ Division Divides one value by another x/y

% Modulus Returns the division remainder x%y


Relational Operators

Operator Description Example

== Is Equal To 3 == 5 returns false

!= Not Equal To 3 != 5 returns true

> Greater Than 3 > 5 returns false

< Less Than 3 < 5 returns true

Greater Than or Equal


>= 3 >= 5 returns false
To

<= Less Than or Equal To 3 <= 5 returns true


Logical Operators

Operator Name Description Example


&& Logical and Returns true if both statements x < 5 && x < 10
are true
|| Logical or Returns true if one of the x < 5 || x < 4
statements is true
! Logical not Reverse the result, returns !(x < 5 && x <
false if the result is true 10)

Ternary Operator

❑ Ternary operator is used as one line replacement for if-then-else


statement and used a lot in Java programming.
condition ? expression1 : expression2;
Assignment Operators

Operator Example Same As


= x=5 x=5
+= x += 3 x=x+3
-= x -= 3 x=x-3
*= x *= 3 x=x*3
/= x /= 3 x=x/3
%= x %= 3 x=x%3
Increment/Decrement Operator
Increment operator is used to increment a value by 1. There are two
varieties of increment operator:
• Post-Increment: Value is first used for computing the result and then
incremented.
• Pre-Increment: Value is incremented first and then the result is computed.
Decrement operator is used for decrementing the value by 1. There
are two varieties of decrement operators.
• Post-decrement: Value is first used for computing the result and then
decremented.
• Pre-decrement: Value is decremented first and then the result is computed.
Bitwise Operators
Bitwise operators are used to performing the manipulation of
individual bits of a number.
Operator Precedence
THANK YOU

You might also like