Page 118 - CA_Blue( J )_Class9
P. 118

12.  What will be printed by the following code?
                         System.out.println("A");
                         System.out.println("B");
                         System.out.println("C");
                         a.  ABC                                        b.  A B C
                         c.  AB                                         d.  ABC with each letter on a new line
                    13.  What is the difference between the prefix and postfix increment operators in Java?
                         a.  Prefix increments the value before it is used, while postfix increments the value after it is used.
                         b.  Prefix increments after it is used, while postfix increments before it is used.
                         c.  Both increment the value simultaneously.
                         d.  Prefix is used with variables, and postfix is used with constants.
                    14.  Consider the following code:
                         int a = 7;
                         int b = a++;
                         What are the values of a and b after execution?
                         a.  a = 6, b = 6                               b.  a = 7, b = 8
                         c.  a = 7, b = 7                               d.  a = 8, b = 7

                    15.  Which of the following statements is true about the postfix decrement operator in Java?
                         a.  It decreases the value by 2.
                         b.  It decreases the value after it is used in the expression.
                         c.  It decreases the value before it is used in the expression.
                         d.  It does not change the value of the variable.
                  B.  Fill in the blanks.

                     1.  ………………… are used to instruct the compiler to execute some operations.
                     2.  The ………………… operator is used to access the member of the class.
                     3.  The ………………… operator is used to create objects.
                     4.  The output of logical operator is in ………………… form.

                     5.  Counters increases by ………………… and in Accumulator, the increment value is ………………… for each recurrence of the
                         loop.

                  C.  Answer the following questions.

                     1.  What is the output of the following expressions if executed sequentially, if m=15, n=5, r=0 and m,n and r all are
                         integers.
                         • r= m++ / ++n
                         • r = ++m + ++n – n++
                     2.  Explain the Arithmetic operators.
                     3.  Write the Java Expression of the following mathematical expressions:
                         • A =  (B + C)  ×h
                                2
                         • V = πr ×h
                               2
                     4.   Give the output of the following expression:
                         •   a = ++a + a-- / ++a + --a; when a = 2.
                         • i *= j++ % j-- / k *10; when i=2,j=4,k=3
                     5.  Name the operators listed below:
                         a.  <                                          b.  ++
                         c.  &&                                         d.  ?:



                   116    Touchpad Computer Applications-IX
   113   114   115   116   117   118   119   120   121   122   123