Page 187 - CA_Blue( J )_Class10
P. 187

13.  Write a menu-driven program to print the following according to the user’s choice:
                       a.   Print 1st n natural numbers and their squares and cubes in tabular form.
                            1   1    1   1
                       b.  s = 1 3  –  2 3  +  3 3  ... n 3
                    14.  Write a program to input n and print the sum of the following series:
                          x+x 2  x+x 3
                         s =   +    +... N
                           2!    3!
                    15.  Write a program to input the salary of 5 employees and calculate the tax according to the following criteria. Also, calculate the
                       total tax collected.
                        Salary                       Tax Rate
                        Up to 20000/-                No Tax
                        Next 15000/-                 5.5%
                        Next 30000/-                 7.5%
                        Above 65000/-                10%


                 D.  Assertion and Reasoning based questions.
                         The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting the appro-
                       priate 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 "break" statement can be used to exit from a loop prematurely.
                        Reason (R): The "break" statement terminates the loop and transfers control to the statement immediately following the loop.
                    2.  Assertion (A): The "continue" statement in a loop causes the loop to terminate
                        Reason (R): The "continue" statement skips the remaining code in the loop's current iteration and proceeds with the next iteration.


                                             Previous Years' Questions




                                                              SECTION A

                    1.  State the type of loop in the given program segment:
                       for (int i = 5; i ! = 0; i - = 2)
                       System.out.println(i);                                                                       [2023]
                       a.  finite                                      b.  infinite
                       c.  null                                        d.  fixed
                   Ans.  a
                    2.  The jump statement that is used inside a switch case construct to terminate a statement  sequence:
                       a.  continue                                    b.  break
                       c.  return                                      d.  goto                                     [2022]
                   Ans.  b
                    3.  Give the output of the following:
                       int x;
                       for ( x=1 ; x<=3; x++ ); System.out.print (x);                                               [2022]
                       a.  1 2 3                                       b.  1 2 3 4
                       c.  4                                           d.  1
                   Ans.  c
                    4.  Give the output of the following:

                       int v=5;
                       while (--v>=0 )  {


                                                                                                                       185
                                                                                              Iterative constructs in Java  185
   182   183   184   185   186   187   188   189   190   191   192