Page 120 - CA_Blue( J )_Class9
P. 120

c.  Subtraction, because operators are evaluated from right to left.
                         d.  Addition, because operators are evaluated from left to right.
                     2.  Which of the following operators in Java has left-to-right associativity?
                         a.  * (multiplication)                         b.  = (assignment)
                         c.  ? : (ternary operator)                     d.  ++ (post-increment)
                     3.  Given the expression x = a - b + c, which statement is true about the order of operations?
                         a.  c is added to b first, then subtracted from a.
                         b.  b  is subtracted from a first, then c is added to the result.
                         c.  The operations are performed based on operator precedence, not associativity.
                         d.  The expression is evaluated from right to left.
                     4.  Which of the following Java operators has right-to-left associativity?
                         a.  + (addition)
                         b.  && (logical AND)
                         c.  = (assignment)
                         d.  - (subtraction)
                     5.  In the expression a + b * c, which operation is executed first?
                         a.  Addition, because it is the leftmost operator.
                         b.  Multiplication, because it has higher precedence than addition.
                         c.  Addition, because addition is generally performed before multiplication.
                         d.  The operations are executed simultaneously.

                  F.  Assertion and Reasoning based question.
                      The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting
                      the appropriate option given below:
                      a.  Both A and R are true, and R is the correct explanation of A.
                      b.  Both A and R are true, but R is not the correct explanation of A.
                      c.  A is true, but R is false.
                      d.  A is false, but R is true.
                      1.  Assertion(A): The logical OR operator (||) in Java always evaluates both operands.
                         Reason(R): The logical OR operator returns true if either of the operands is true.
                      2.  Assertion(A): In Java, the ternary operator (? :) has higher precedence than the assignment operator (=).
                          Reason(R): Operators with higher precedence are evaluated before operators with lower precedence in an expres-
                         sion.































                   118    Touchpad Computer Applications-IX
   115   116   117   118   119   120   121   122   123   124   125