Page 152 - CA_Blue( J )_Class10
P. 152

3.  int f= 10,m=9;                                                                              [2022]
                     String e=(m%f==9) ? "YES" : "NO";
                     System.out.print(e);
                    a.  YES                                         b.  NO
                    c.  YESNO                                       d.  NOYES
                Ans.  a
                  4.  Give the output of the following:                                                           [2022]
                    switch(x){
                    case 'M':
                    System.out.print("Microsoft Teams"); break;
                    case 'G':
                          System.out.print("Google Meet"); default :
                    System.out.print("Any software");
                    break; case 'W':
                    System.out.print("Web Ex");
                    break;
                    }
                     When x='g'
                    a.  Google Meet                                 b.  Any software
                    c.  Google Meet                                 d.  WebEx
                Ans.  b
                  5.  If the value of basic = 1500, what will be the value of tax after the following statement is executed?
                     tax = basic > 1200 ? 200 : 100;                                                              [2019]
                Ans.  tax = 200
                  6.  Differentiate between if-else-if and switch statements.                                     [2019]
                Ans.
                                  if-else-if statement                            switch statement
                     Evaluates the relational expression.       Evaluates a single value which is used to determine which case is
                                                                to be executed.
                     Evaluate almost all the types of data      Evaluate either an integer or a character.

                  7.  Convert the following if else if construct into switch case:                                [2018]
                     if(var == 1)
                         System.out.println("good");
                     else if(var == 2)
                         System.out.println("better");
                     else if(var == 3)
                         System.out.println("best");
                     else
                         System.out.println("invalid");
                Ans. switch(var)
                    {
                        case 1:    System.out.println("good");
                                   break;
                        case 2:    System.out.println("better");
                                   break;
                        case 3:    System.out.println("best");
                                   break;
                        default:   System.out.println("invalid");
                    }



                150150  Touchpad Computer Applications-X
   147   148   149   150   151   152   153   154   155   156   157