Page 108 - CA_Blue( J )_Class9
P. 108

Each element of the array is automatically initialized to the default value of int, which is 0.
                  Thus, the new operator is essential in Java for instantiating objects and arrays, allocating dynamic memory, and
                  initializing reference types.


                       5.5 HIERARCHY OF OPERATORS
                  The hierarchy of operators, also known as operator precedence that determines the sequence in which operations
                  are performed in an expression. Java also uses this concept to calculate the result of an expression according to
                  the relative importance of the operators.
                  Precedence of operators refers to the order in which the operators will be evaluated in an expression. Java uses
                  this precedence when an expression contains two or more operators.
                  Java's operator precedence is more complex than the simple BEDMAS rule used in basic arithmetic. It involves
                  arithmetic, logical, relational, and other operators, all with specific precedence levels.

                                                           Exponents
                                                                 Multiplication



                                       Bracket                                           Subtraction


                                                               Division
                                                                      Addition


                  For example:
                         int m=10, n=25, d;
                            d = m++ + (n - m) % 2;
                               = 10 + (25 - 11) % 2
                               = 10 + 14 % 2
                               = 10 + 0
                               = 10
                         Hence, d=10, and m=11 as postfix increment shows after the completion of expression.

                       Hierarchy                 Operators                               Precedence
                          1.         postfix unary                     ++, --

                          2.         unary including prefix, logical NOT  ++, --, +, -, ~ ,!
                          3.         multiplication, division and modulus *, /, %
                          4.         addition and subtraction          +, -

                          5.         bitwise shift                     <<, >>, >>>
                          6.         relational                        <, >, <=, >=
                          7.         equality, in-equality             ==, !=
                          8.         bitwise AND                       &
                          9.         bitwise exclusive OR              ^

                          10.        bitwise inclusive OR              |
                          11.        logical AND                       &&




                   106    Touchpad Computer Applications-IX
   103   104   105   106   107   108   109   110   111   112   113