Page 148 - CA_Blue( J )_Class10
P. 148

{    System.out.println("Child");                   }
                     else if (age < 30)
                     {    System.out.println("Young Adult");            }
                    else if (age < 50)
                     {    System.out.println("Adult");                  }
                    else
                    {    System.out.println("Senior");                  }
                    a.  Child                                       b.  Young Adult
                    c.  Adult                                       d.  Senior
                 14.  What will be the output of the following code snippet?
                    int x = 5, y = 15;
                    if (x > 3 && y < 20)
                    {    System.out.println("Condition met");                  }
                    else
                     {    System.out.println("Condition not met");             }
                    a.  Condition met                               b.  Condition not met
                    c.  Compilation error                           d.  Runtime error
                 15.  What will be the output of the following code snippet if day is set to 5?
                    int day = 5;
                    switch (day) {
                        case 1:
                            System.out.println("Monday");
                            break;
                        case 2:
                            System.out.println("Tuesday");
                            break;
                        case 3:
                            System.out.println("Wednesday");
                            break;
                        default:
                            System.out.println("Invalid day");
                    }
                    a.  Monday                                      b.  Tuesday
                    c.  Wednesday                                   d.  Invalid day

              B.  Fill in the blanks.

                  1.  Java Ternary operator is also called ………………….
                  2.  The absence of break in ………………… statement is known as fall-through.
                  3.  One example of ………………… statement is a switch case statement.
                  4.  The if(a == 0) will return ………………… when a is a non-zero value.
                  5.  The if…else statement always returns ………………… data type.

              C.  Answer the following questions.
                  1.  What is the difference between if and if…else statements?
                  2.  What are compound statements?
                  3.  What is a fall-through situation?
                  4.  What is the use of the break statement in the switch statement?



                146146  Touchpad Computer Applications-X
   143   144   145   146   147   148   149   150   151   152   153