SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
- 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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Data types in java
Data types in javaData types in java
Data types in java
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentation
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Applets
AppletsApplets
Applets
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Constructors and Destructor in C++
Constructors and Destructor in C++Constructors and Destructor in C++
Constructors and Destructor in C++
 
Operators in java
Operators in javaOperators in java
Operators in java
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 

Andere mochten auch

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 javaJaved Rashid
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programmingManoj Tyagi
 
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 javaAtul 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 JavaOblivionWalker
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in CPrabhu Govind
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritanceadil raja
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )Adarsh Patel
 

Andere mochten auch (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
 
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
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
 

Ähnlich wie Operators and Expressions in Java

Chpt 2-functions-seqs v.5
Chpt 2-functions-seqs v.5Chpt 2-functions-seqs v.5
Chpt 2-functions-seqs v.5ShahidAkbar22
 
Module Seven Lesson Four Remediation Notes
Module Seven Lesson Four Remediation NotesModule Seven Lesson Four Remediation Notes
Module Seven Lesson Four Remediation Notesncvpsmanage1
 
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_.pptxdatumanongnormalah
 
Relations and Functions #BB2.0.pdf
Relations and Functions #BB2.0.pdfRelations and Functions #BB2.0.pdf
Relations and Functions #BB2.0.pdfAakashKushwaha26
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptxrinkugupta37
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operatorsAnuja 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 detailgourav kottawar
 
2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functionssmiller5
 
Tema 1 funciones
Tema 1 funcionesTema 1 funciones
Tema 1 funcionesMrYerk
 
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 TrainingRahul Tandale
 

Ähnlich wie Operators and Expressions in Java (20)

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
 
Report on c
Report on cReport on c
Report on c
 

Mehr von Abhilash Nair

Sequential Circuits - Flip Flops
Sequential Circuits - Flip FlopsSequential Circuits - Flip Flops
Sequential Circuits - Flip FlopsAbhilash Nair
 
Designing Clocked Synchronous State Machine
Designing Clocked Synchronous State MachineDesigning Clocked Synchronous State Machine
Designing Clocked Synchronous State MachineAbhilash Nair
 
VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)Abhilash Nair
 
Introduction to VHDL - Part 1
Introduction to VHDL - Part 1Introduction to VHDL - Part 1
Introduction to VHDL - Part 1Abhilash Nair
 
Feedback Sequential Circuits
Feedback Sequential CircuitsFeedback Sequential Circuits
Feedback Sequential CircuitsAbhilash Nair
 
Designing State Machine
Designing State MachineDesigning State Machine
Designing State MachineAbhilash Nair
 
State Machine Design and Synthesis
State Machine Design and SynthesisState Machine Design and Synthesis
State Machine Design and SynthesisAbhilash Nair
 
Synchronous design process
Synchronous design processSynchronous design process
Synchronous design processAbhilash 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 modelsAbhilash Nair
 
Analysis of state machines
Analysis of state machinesAnalysis of state machines
Analysis of state machinesAbhilash 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
 

Mehr von 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
 

Kürzlich hochgeladen

How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxiammrhaywood
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 

Kürzlich hochgeladen (20)

How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 

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