Page 633 - ComputerScience_Class_11
P. 633

(ix)  Assertion (A): 7 %  - 4 = 3                                                                 [1]
                          Reasoning (R): The result should be -3 as the divisor  has negative sign
                          (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, R is false.
                          (d)  A is false, R is true.
                      (x)  Assertion (A): Method overloading is an example of compile-time polymorphism.               [1]
                          Reason (R): The method call is resolved at runtime based on the object.
                          (a)  Both A and R are true and R is correct explanation of A
                          (b)  Both A and R are true, but R is not correct explanation
                          (c)  A is true, R is false
                          (d)  A is false, R is true
                 Question 2:
                      (i)  Write the equivalent Java statement for the following expression.                           [2]
                              2
                             x  + y 2
                         F =
                              2  xy
                      (ii)  Define  a String array ‘metro’ storing the following names:                                [2]
                          NEW DELHI, MUMBAI, KOLKATA, CHENNAI, HYDERABAD
                     (iii)  The following function is a part of some class which computes and returns the value of a number ‘p’ raised to the power ‘q’
                          q
                         (p ).. There are some places in the code marked by ?1? , ?2? , ?3? which must be replaced by an expression/a statement so
                         that the function works correctly.
                         double power ( double p , int q )
                         { double r = ?1? ;
                             int c = ( q<0 ) ? -q : q ;
                             if ( q == 0)
                                    return 1 ;
                             else
                             { for (int i = 1; i <= c , i++)
                                           r=?2?;
                                 return (q>0)? r : ?3?;
                         }
                         }
                          (a)  What is the expression or statement at ?1? , ?2? and ?3?                                [3]
                     (iv)  Predict the output for the following python code:                                           [3]

                         for i in range(1, 5):
                             for j in range(i):
                                 if j %2==0:
                                    print(i*'*', end=" ")
                                 else:
                                     print(i*j,end=" ")
                             print()

















                                                                                                     Sample Paper  631
   628   629   630   631   632   633   634   635   636   637   638