Page 119 - CA_Blue( J )_Class9
P. 119

6.   Write the output:
                        char ch = 'F';
                        int m = ch;
                        m = m + 5;
                        System.out.println(m + " " + ch);
                    7.   Differentiate between counter and accumulator.
                    8.   Differentiate between the following:
                        a.  Arithmetical operator and Logical operator    b.  Logical AND and Logical OR
                    9.  Define postfix increment operator.
                    10.   What will be the output of the following code?
                        int m = 2;                              int n = 15;
                        for(int i = 1; i < 5; i++)
                        m++;
                        --n;

                        System.out.println("m = " + m);
                        System.out.println("n = " + n);

                 D.  Picture Study.

                                                        TYPES OF OPERATORS





                      Arithmetic   Relational     Logical     Bitwise    Assignment   Conditional    Misc.
                       operators    operators   operators    operators    operators    operators    operators

                    1.  > , < are ………………… operators
                        a.  Logical                                    b.  Relational
                        c.  Assignment                                 iv.  Conditional
                    2.  ! is called ………………… and is under ………………… operator.
                        a.  Not, Relational                            b.  Not, Logical
                        c.  And, Logical                               d.  Or, Assignment
                    3.  What will be the output?
                        System.out.println(x=7);
                        a.  7                                          b.  true
                        c.  false                                      d.  Error
                    4.  Ternary operator (?:) is also called:
                        a.  Relational                                 b.  Arithmetic
                        c.  Conditional                                d.  Logical
                    5.  Identify the operator that checks whether the expression is true or false.
                        a.  Relational                                 b.  Arithmetic
                        c.  Conditional                                d.  Logical
                                                                                                21 st
                 E.  Case Study.                                                             Century   #Experiential Learning
                                                                                               Skills
                     Some operators have same hierarchy. In that case, the calculation is done according to their associativity, which is either
                     from left to right or vice versa. Suppose, in an expression “a+b-c” the + and – is there without any parenthesis, so since
                     the binary operators has left to right associativity, the addition will be executed before the subtraction.
                    1.  In the expression a + b - c, which operation is performed first?
                        a.  Subtraction, because it has higher precedence.
                        b.  Addition, because it has higher precedence.



                                                                                               Operators in Java   117
   114   115   116   117   118   119   120   121   122   123   124