Page 79 - CA_Blue( J )_Class10
P. 79

a -= (a--) - (--a)
                        a-= 6-4
                        a-=2
                        a=a-2
                        a=6-2
                        a=4
                    18.  What is meant by precedence of operators?                                                  [2013]
                   Ans.  Precedence of operators means the way in which expressions will be calculated to obtain a correct result.
                                                    2
                    19.  Write a Java expression for ut + 1/2 ft                                                    [2013]
                   Ans.  u * t + 1 / 2 * f * t * t
                    20.  Give one point of difference between unary and binary operators.                           [2012]
                   Ans.
                             Unary Operator            Binary Operator
                       Acts on one operand       Acts on two operands
                       Example: a++              Example: a+b
                    21.  Write a Java expression for:  (2as+u ) .                                                   [2012]
                                                   2
                   Ans.  Math.sqrt(2 * a * s + u * u)
                    22.  What are the values of x and y when the following statements are executed?
                        int a = 63, b = 36;
                        boolean x = (a > b)? true : false;
                        int y = (a < b)? a : b;                                                                     [2012]
                   Ans.  x = true                                      [Explanation: x=63>36, so true]
                        y = 36                                         [Explanation: y=63 < 36, so 36]
                    23.  State the values of n and ch.
                        char c = 'A';
                        int n = c + 1;
                        char ch = (char)n;                                                                          [2012]
                   Ans.  n = 66
                        ch = ‘B’
                        [Explanation: ASCII value of ‘A’ is 65,
                        n = 65+1                                       (implicit conversion)
                        ch = B                                         (explicit conversion)]
                    24.  What will be the result stored in x after evaluating the following expression?

                        int x = 4;
                        x += (x++) + (++x) + x;                                                                     [2012]
                   Ans.  x = x + x++ + ++x + x;
                        = 4 + 4 + 6 + 6;
                        = 20


























                                                                                                                       77
                                                                                                      Operators in Java   77
   74   75   76   77   78   79   80   81   82   83   84