SlideShare a Scribd company logo
- Ankita Karia




Ankita R Karia   1 February 2012   1
   JAVA operators can be classified into a number of related
    categories as below:-
      Arithmetic.            + - * / %


      Relational.         < <= > >= == !=
                              &&              ||                      !
      Logical.              AND              OR                     NOT

                         T && T = T F || F= F                       T=F
                                                                    F=T
                                        Ankita R Karia   1 February 2012   2
ASSIGNMENT         CONDITIONAL                         INCREMENT
         =                 ? :                                ++
• Is used to      exp1 ? exp2 : exp3                   •PRE:- First
assign value to   e.g.:- x=(a>b)?a:b                   subtracts 1 from
                                                       operand and then the
variable.                                              result is assigned .
e.g.:- a =10        DECREMENT - -                             ++m;
•SHORTHAND
     a=a+1        • PRE:- First subtracts 1            •POST:- First
                                                       assigns the value to
Can also be       from operand and then the
                                                       the variable on left and
                  result is assigned .
written as            - - m;                           then decrements
      a+=1                                             operand
                  •POST:- First assigns the
                                                               m++
a = a / (n+1)     value to the variable on left
                  and then decrements
                  operand
                      m--                   Ankita R Karia   1 February 2012   3
   JAVA permits mixing of constants and variables of different
    types in an expression, but during evaluation it adheres to
    very strict rules of type conversion.
   If operands are of different types, the “lower” type is
    automatically converted to “higher” type before the operation
    proceeds. The result is of higher type.
   The final result of an expression is converted to the type of
    the variable on the left of the assignment before assigning the
    value

                                              Ankita R Karia   1 February 2012   4
EXAMPLES                       ACTION
x= (int) 7.5             7.5 is converted to integer by
                         truncation
a = (int)21.3/(int)4.5   Evaluated as 21/4 and the result
                         would be 5
b = (double) sum/n       Division is done in floating point
                         mode
y = (int) (a+b)          The result of a+b is converted to
                         integer
y = (int) a+b            a is converted to integer and then
                         added to b

p = cost ((double)x)     Converts x to double before using
                         it as parameter
                                  Ankita R Karia   1 February 2012   5
   JAVA supports basic math functions through Math class
    defined in the java.lang.package.
   The functions should be used as follows:-

            Math.function_name();
                         java.lang.Math
 Example: y = Math.sqrt(x);



                                        Function
                                         name
                                           Ankita R Karia   1 February 2012   6
FUNCTIONS                        ACTION
   sin(x)      Returns the sine of the angle x in radians
  cos(x)      Returns the cosine of the angle x in radians
   tan(x)     Returns the tangent of the angle x in radians
  asin(x)          Returns the angle whose sine is y
 atan2(x,y)     Returns the angle whose tangent is x/y
 pow(x,y)                        Returns xy
  exp(x)                         Returns ex
   log(x)          Returns the natural logarithm of x
  sqrt(x)               Returns square root of x
  abs(x)                  Returns absolute of x
 max(a,b)            Returns maximum of1 a and b
                                Ankita R Karia February 2012   7
 Determine   the value of the following
 arithmetic expression. (a=5,b=2,c=1)
1. m = ++a*5;

2. p*=x/y; x=10,y=2,p=2;

3. s/=5;   s=5;
4. n=b++-c*2;

                               Ankita R Karia   1 February 2012   8
Ankita R Karia   1 February 2012   9
Ankita R Karia   1 February 2012   10
   Determine the value of the following logical
    expression. (a=5,b=10,c=-6)
1. a<b && a<c;

2. a<b && a>c;

3. a= = c || b>a;

4. b>15 && c<0 || a>0;

5. (a/2.0==0.0&&b/2.0!=0.0)||c<0.0

                                  Ankita R Karia   1 February 2012   11
Ankita R Karia   1 February 2012   12
1. The straight-line method of computing the yearly depreciation of the value of an item
   is given by
                depreciation = Purchase Price – Salvage Value
                                     Years of service
  Write a program to determine the salvage value of an item when the purchase price,
                  years of service and Annual depreciation are given

                                                        Ankita R Karia   1 February 2012   13

More Related Content

What's hot

Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in JavaJin Castor
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Hitesh Kumar
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
03062679929
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaAbhilash Nair
 
Method overriding
Method overridingMethod overriding
Method overriding
Azaz Maverick
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Functions in C
Functions in CFunctions in C
Functions in C
Kamal Acharya
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
Java exception
Java exception Java exception
Java exception
Arati Gadgil
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
Elizabeth alexander
 
Java Tokens
Java  TokensJava  Tokens
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vishal Patil
 

What's hot (20)

Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in Java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Java input
Java inputJava input
Java input
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
 
Method overriding
Method overridingMethod overriding
Method overriding
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
JVM
JVMJVM
JVM
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Java exception
Java exception Java exception
Java exception
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 

Viewers also liked

Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressionsvishaljot_kaur
 
Control statements in Java
Control statements  in JavaControl statements  in Java
Control statements in JavaJin Castor
 
Control structures i
Control structures i Control structures i
Control structures i
Ahmad Idrees
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
Manoj Tyagi
 
Operators in java
Operators in javaOperators in java
Operators in java
Muthukumaran Subramanian
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in JavaRavi_Kant_Sahu
 
Təhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyaları
Təhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyalarıTəhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyaları
Təhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyaları
Irkan Akhmedov
 
Fişinqdən necə qorunmaq olar?
Fişinqdən necə qorunmaq olar?Fişinqdən necə qorunmaq olar?
Fişinqdən necə qorunmaq olar?
Irkan Akhmedov
 
itft-Operators in java
itft-Operators in javaitft-Operators in java
itft-Operators in java
Atul Sehdev
 
Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...
Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...
Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...
Irkan Akhmedov
 
C++ Multiple Inheritance
C++ Multiple InheritanceC++ Multiple Inheritance
C++ Multiple Inheritanceharshaltambe
 
Regular Expressions in Java
Regular Expressions in JavaRegular Expressions in Java
Regular Expressions in Java
OblivionWalker
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
Prabhu Govind
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
adil raja
 

Viewers also liked (20)

Operators in java
Operators in javaOperators in java
Operators in java
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
Control statements in Java
Control statements  in JavaControl statements  in Java
Control statements in Java
 
Control structures i
Control structures i Control structures i
Control structures i
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
 
Java 2
Java 2Java 2
Java 2
 
Təhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyaları
Təhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyalarıTəhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyaları
Təhlükəsiz proqram təminatının java mühitində hazırlanma texnologiyaları
 
Fişinqdən necə qorunmaq olar?
Fişinqdən necə qorunmaq olar?Fişinqdən necə qorunmaq olar?
Fişinqdən necə qorunmaq olar?
 
itft-Operators in java
itft-Operators in javaitft-Operators in java
itft-Operators in java
 
Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...
Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...
Java proqramlaşdirma mühitində təhlükəsiz proqram təminatinin hazirlanma texn...
 
Jdbc
JdbcJdbc
Jdbc
 
C++ Multiple Inheritance
C++ Multiple InheritanceC++ Multiple Inheritance
C++ Multiple Inheritance
 
Regular Expressions in Java
Regular Expressions in JavaRegular Expressions in Java
Regular Expressions in Java
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
Basic JSTL
Basic JSTLBasic JSTL
Basic JSTL
 
15 bitwise operators
15 bitwise operators15 bitwise operators
15 bitwise operators
 

Similar to Operators and Expressions in Java

MATH-412-TUMANDAY Report in Mat-Math.pptx
MATH-412-TUMANDAY Report in Mat-Math.pptxMATH-412-TUMANDAY Report in Mat-Math.pptx
MATH-412-TUMANDAY Report in Mat-Math.pptx
JoelynRubio1
 
Chpt 2-functions-seqs v.5
Chpt 2-functions-seqs v.5Chpt 2-functions-seqs v.5
Chpt 2-functions-seqs v.5
ShahidAkbar22
 
Module Seven Lesson Four Remediation Notes
Module Seven Lesson Four Remediation NotesModule Seven Lesson Four Remediation Notes
Module Seven Lesson Four Remediation Notes
ncvpsmanage1
 
power point presentation on genmath_lesson1_2_.pptx
power point presentation on genmath_lesson1_2_.pptxpower point presentation on genmath_lesson1_2_.pptx
power point presentation on genmath_lesson1_2_.pptx
datumanongnormalah
 
C language basics
C language basicsC language basics
C language basics
Milind Deshkar
 
Relations and Functions #BB2.0.pdf
Relations and Functions #BB2.0.pdfRelations and Functions #BB2.0.pdf
Relations and Functions #BB2.0.pdf
AakashKushwaha26
 
Inverse function
Inverse function Inverse function
Inverse function
RidhimaPangtey
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
rinkugupta37
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
Mohammad Imam Hossain
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
Anuja Lad
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
gourav kottawar
 
2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functions
smiller5
 
Tema 1 funciones
Tema 1 funcionesTema 1 funciones
Tema 1 funciones
MrYerk
 
Paper no. 4
Paper no. 4Paper no. 4
Paper no. 4
Rhea Mae Esmaña
 
Paper no. 4
Paper no. 4Paper no. 4
Paper no. 4
Rhea Mae Esmaña
 
Indefinite Integration One shot Revision
Indefinite Integration One shot Revision Indefinite Integration One shot Revision
Indefinite Integration One shot Revision
CHANDHINIJAYARAMAN
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online Training
Rahul Tandale
 
BP106RMT.pdf
BP106RMT.pdfBP106RMT.pdf
BP106RMT.pdf
BurhaanBhat1
 

Similar to Operators and Expressions in Java (20)

MATH-412-TUMANDAY Report in Mat-Math.pptx
MATH-412-TUMANDAY Report in Mat-Math.pptxMATH-412-TUMANDAY Report in Mat-Math.pptx
MATH-412-TUMANDAY Report in Mat-Math.pptx
 
Chpt 2-functions-seqs v.5
Chpt 2-functions-seqs v.5Chpt 2-functions-seqs v.5
Chpt 2-functions-seqs v.5
 
Module Seven Lesson Four Remediation Notes
Module Seven Lesson Four Remediation NotesModule Seven Lesson Four Remediation Notes
Module Seven Lesson Four Remediation Notes
 
power point presentation on genmath_lesson1_2_.pptx
power point presentation on genmath_lesson1_2_.pptxpower point presentation on genmath_lesson1_2_.pptx
power point presentation on genmath_lesson1_2_.pptx
 
C language basics
C language basicsC language basics
C language basics
 
Relations and Functions #BB2.0.pdf
Relations and Functions #BB2.0.pdfRelations and Functions #BB2.0.pdf
Relations and Functions #BB2.0.pdf
 
Inverse function
Inverse function Inverse function
Inverse function
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
 
Functions
FunctionsFunctions
Functions
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
 
2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functions
 
Unit 4
Unit 4Unit 4
Unit 4
 
Tema 1 funciones
Tema 1 funcionesTema 1 funciones
Tema 1 funciones
 
Paper no. 4
Paper no. 4Paper no. 4
Paper no. 4
 
Paper no. 4
Paper no. 4Paper no. 4
Paper no. 4
 
Indefinite Integration One shot Revision
Indefinite Integration One shot Revision Indefinite Integration One shot Revision
Indefinite Integration One shot Revision
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online Training
 
BP106RMT.pdf
BP106RMT.pdfBP106RMT.pdf
BP106RMT.pdf
 

More from Abhilash Nair

Sequential Circuits - Flip Flops
Sequential Circuits - Flip FlopsSequential Circuits - Flip Flops
Sequential Circuits - Flip Flops
Abhilash Nair
 
VHDL Part 4
VHDL Part 4VHDL Part 4
VHDL Part 4
Abhilash Nair
 
Designing Clocked Synchronous State Machine
Designing Clocked Synchronous State MachineDesigning Clocked Synchronous State Machine
Designing Clocked Synchronous State Machine
Abhilash Nair
 
MSI Shift Registers
MSI Shift RegistersMSI Shift Registers
MSI Shift Registers
Abhilash Nair
 
VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)
Abhilash Nair
 
VHDL - Part 2
VHDL - Part 2VHDL - Part 2
VHDL - Part 2
Abhilash Nair
 
Introduction to VHDL - Part 1
Introduction to VHDL - Part 1Introduction to VHDL - Part 1
Introduction to VHDL - Part 1
Abhilash Nair
 
Feedback Sequential Circuits
Feedback Sequential CircuitsFeedback Sequential Circuits
Feedback Sequential Circuits
Abhilash Nair
 
Designing State Machine
Designing State MachineDesigning State Machine
Designing State Machine
Abhilash Nair
 
State Machine Design and Synthesis
State Machine Design and SynthesisState Machine Design and Synthesis
State Machine Design and Synthesis
Abhilash Nair
 
Synchronous design process
Synchronous design processSynchronous design process
Synchronous design process
Abhilash Nair
 
Analysis of state machines & Conversion of models
Analysis of state machines & Conversion of modelsAnalysis of state machines & Conversion of models
Analysis of state machines & Conversion of models
Abhilash Nair
 
Analysis of state machines
Analysis of state machinesAnalysis of state machines
Analysis of state machines
Abhilash Nair
 
Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)
Abhilash Nair
 
Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)
Abhilash Nair
 
FPGA
FPGAFPGA
FPLDs
FPLDsFPLDs
CPLDs
CPLDsCPLDs
CPLD & FPLD
CPLD & FPLDCPLD & FPLD
CPLD & FPLD
Abhilash Nair
 
CPLDs
CPLDsCPLDs

More from Abhilash Nair (20)

Sequential Circuits - Flip Flops
Sequential Circuits - Flip FlopsSequential Circuits - Flip Flops
Sequential Circuits - Flip Flops
 
VHDL Part 4
VHDL Part 4VHDL Part 4
VHDL Part 4
 
Designing Clocked Synchronous State Machine
Designing Clocked Synchronous State MachineDesigning Clocked Synchronous State Machine
Designing Clocked Synchronous State Machine
 
MSI Shift Registers
MSI Shift RegistersMSI Shift Registers
MSI Shift Registers
 
VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)
 
VHDL - Part 2
VHDL - Part 2VHDL - Part 2
VHDL - Part 2
 
Introduction to VHDL - Part 1
Introduction to VHDL - Part 1Introduction to VHDL - Part 1
Introduction to VHDL - Part 1
 
Feedback Sequential Circuits
Feedback Sequential CircuitsFeedback Sequential Circuits
Feedback Sequential Circuits
 
Designing State Machine
Designing State MachineDesigning State Machine
Designing State Machine
 
State Machine Design and Synthesis
State Machine Design and SynthesisState Machine Design and Synthesis
State Machine Design and Synthesis
 
Synchronous design process
Synchronous design processSynchronous design process
Synchronous design process
 
Analysis of state machines & Conversion of models
Analysis of state machines & Conversion of modelsAnalysis of state machines & Conversion of models
Analysis of state machines & Conversion of models
 
Analysis of state machines
Analysis of state machinesAnalysis of state machines
Analysis of state machines
 
Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)
 
Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)
 
FPGA
FPGAFPGA
FPGA
 
FPLDs
FPLDsFPLDs
FPLDs
 
CPLDs
CPLDsCPLDs
CPLDs
 
CPLD & FPLD
CPLD & FPLDCPLD & FPLD
CPLD & FPLD
 
CPLDs
CPLDsCPLDs
CPLDs
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 

Operators and Expressions in Java

  • 1. - Ankita Karia Ankita R Karia 1 February 2012 1
  • 2. JAVA operators can be classified into a number of related categories as below:-  Arithmetic. + - * / %  Relational. < <= > >= == != && || !  Logical. AND OR NOT T && T = T F || F= F T=F F=T Ankita R Karia 1 February 2012 2
  • 3. ASSIGNMENT CONDITIONAL INCREMENT = ? : ++ • Is used to exp1 ? exp2 : exp3 •PRE:- First assign value to e.g.:- x=(a>b)?a:b subtracts 1 from operand and then the variable. result is assigned . e.g.:- a =10 DECREMENT - - ++m; •SHORTHAND a=a+1 • PRE:- First subtracts 1 •POST:- First assigns the value to Can also be from operand and then the the variable on left and result is assigned . written as - - m; then decrements a+=1 operand •POST:- First assigns the m++ a = a / (n+1) value to the variable on left and then decrements operand m-- Ankita R Karia 1 February 2012 3
  • 4. JAVA permits mixing of constants and variables of different types in an expression, but during evaluation it adheres to very strict rules of type conversion.  If operands are of different types, the “lower” type is automatically converted to “higher” type before the operation proceeds. The result is of higher type.  The final result of an expression is converted to the type of the variable on the left of the assignment before assigning the value Ankita R Karia 1 February 2012 4
  • 5. EXAMPLES ACTION x= (int) 7.5 7.5 is converted to integer by truncation a = (int)21.3/(int)4.5 Evaluated as 21/4 and the result would be 5 b = (double) sum/n Division is done in floating point mode y = (int) (a+b) The result of a+b is converted to integer y = (int) a+b a is converted to integer and then added to b p = cost ((double)x) Converts x to double before using it as parameter Ankita R Karia 1 February 2012 5
  • 6. JAVA supports basic math functions through Math class defined in the java.lang.package.  The functions should be used as follows:- Math.function_name(); java.lang.Math  Example: y = Math.sqrt(x); Function name Ankita R Karia 1 February 2012 6
  • 7. FUNCTIONS ACTION sin(x) Returns the sine of the angle x in radians cos(x) Returns the cosine of the angle x in radians tan(x) Returns the tangent of the angle x in radians asin(x) Returns the angle whose sine is y atan2(x,y) Returns the angle whose tangent is x/y pow(x,y) Returns xy exp(x) Returns ex log(x) Returns the natural logarithm of x sqrt(x) Returns square root of x abs(x) Returns absolute of x max(a,b) Returns maximum of1 a and b Ankita R Karia February 2012 7
  • 8.  Determine the value of the following arithmetic expression. (a=5,b=2,c=1) 1. m = ++a*5; 2. p*=x/y; x=10,y=2,p=2; 3. s/=5; s=5; 4. n=b++-c*2; Ankita R Karia 1 February 2012 8
  • 9. Ankita R Karia 1 February 2012 9
  • 10. Ankita R Karia 1 February 2012 10
  • 11. Determine the value of the following logical expression. (a=5,b=10,c=-6) 1. a<b && a<c; 2. a<b && a>c; 3. a= = c || b>a; 4. b>15 && c<0 || a>0; 5. (a/2.0==0.0&&b/2.0!=0.0)||c<0.0 Ankita R Karia 1 February 2012 11
  • 12. Ankita R Karia 1 February 2012 12
  • 13. 1. The straight-line method of computing the yearly depreciation of the value of an item is given by depreciation = Purchase Price – Salvage Value Years of service Write a program to determine the salvage value of an item when the purchase price, years of service and Annual depreciation are given Ankita R Karia 1 February 2012 13