Thursday, 31 August 2023

Class IX - Computer Applications - Chapter 5: Operators in Java

                 Class IX - Computer Applications

 Chapter 5: Operators in Java

Content 

------------------------------------------------------------------------------------------------------------------------------------------------------

1. Operators and its forms

2. Operators -:Types

3. Operators - Precedence and Associativity

4. Operators - The new Operator

5. Operators - The dot(.) Operator

6. Operators - Expressions

7. Operators - Type Conversions

8. Operators - Output using println and print    

------------------------------------------------------------------------------------------------------------------------------------------------------

 Operators - Definition

  Operators are the symbols(+, -, *, /, %, &&, ||, !, >, <, <=,>=, ==, and ! =) which are used for doing calculations. 

 Operators - Types 
    Operators are of following types:-

  • Mathematical Operators
    • Unary                                      
      • Example int x=10, x++ ++x x-- or --x
    • Binary                                     
      • Example int x=10,y=5, z;  z=x+y, z=x-y
    • Ternary                                   
      • Example int res=(x>y)?60:70;
  • Relational Operators
    • > More than                            
      • Example int x=10, if(x>7)
    • < Less than                              
      • Example int x=10, if(x<7)
    • >= More than Equal to            
      •  Example int x=10, if(x>=7)
    • <= Less than Equal to             
      •  Example int x=10, if(x<=7)
    • == Equal to                             
      • Example int x=10, if(x==7)
    • != Not Equal to                        
      • Example int x=10, if(x!=7)
  • Logical Operators
    • Logical && (AND)
    • Logical || (OR)
    • Logical ! (NOT)

Operators - Precedence and Associativity

Category

Operators

Associativity

Postfix

                     ++ - -

Left to right

Unary

                     + - ! ~ ++ - -

Right to left

Multiplicative

                     * / %

Left to right

Additive

                     + -

Left to right

Shift

                     << >>

Left to right

Relational

                     < <= > >=

Left to right

Equality

                     == !=

Left to right

Bitwise  AND

&

Left to right

Bitwise XOR

^

Left to right

Bitwise OR

|

Left to right

Logical AND

&&

Left to right

Logical OR

||

Left to right

Conditional

?:

Right to left

Assignment

= += -= *= /= %=>>= <<= &= ^= |=

Right to left

Operators - The new Operator

The new Operator used to create object of a class.
              Example: Employee e = new Employee();
 

Operators - The dot(.) Operator

The dot(.) Operator used to access methods of a class
               Example:  e.CalSalary(); 
 
Operators - Expressions
                An expression is a combination of constants, variables, operators and methods calls, which are constructed according to the syntax of the language.
Types of Expressions
  • Arithmetic Expressions
  • String Expressions
  • Boolean(or Logical) Expressions   
Operators - Type Conversions
                A types conversion is a process of converting a value of one data type to another data type.
                Types of Conversions
  • Implicit Conversions

                                     When conversion done automatically  

  •  Explicit Conversions                    

                       When conversion done forcefully

Example: 

int x, y, z;
float  p=7.6F;


 Operators - Output using println and print   

 Logical


Operators - Very Short Answer Type Questions

Operators - Short Answer Type Questions

Operators - Programming Based Questions

 



 



 

 


No comments:

Post a Comment

CLASS X TYPES OF NUMBERS

 CLASS X  TYPES OF NUMBERS List of types of Numbers 1. Arm Strong Number 2.  Co-prime Number 3. Duck Number [I.C.S.E 2024] 4. Magic Number  ...