Page 163 - Computer science 868 Class 12
P. 163

int integer = 10, convert;
                            convert = integer >> 2; // 2 bit signed right shift
                            System.out.println(convert);
                        }
                    }
                   The output of the preceding program is as follows:














                 3.  Unsigned Right Shift Operator
                    class unsigned_right_operator
                    {
                        public static void main()
                        {
                            byte n1 = 10;
                            byte n2 = -10;
                            System.out.println(n1 >>> 2);
                            System.out.println(n2 >>> 2);
                        }
                    }
                   The output of the preceding program is as follows:
















                 6.5.6 Assignment Operator
                 We know that a variable is assigned some value to perform some task in a program. This is called the assignment
                 statement and the symbol ‘=’ used in this statement is known as an assignment operator. The left of the assignment
                 operator is a variable that stores the value that is on the right side of the assignment operator.

                 Let us understand this by taking the example given below.
                    c = a + b;
                 Here, the sum of the values of the variables “a” and “b” is stored in the variable “c” with the help of “=” symbol. This
                 “=” symbol is called an assignment operator. But, there is a restriction. While assigning the values, the data types on
                 both sides must be the same, i.e., integer value must be assigned to an int data type. Else there will be a requirement
                 for explicit conversion of values.





                                                                                                                       161
                                                                                               Variables and Expressions   161
   158   159   160   161   162   163   164   165   166   167   168