Page 89 - iPlus_Ver_2.0_class_8
P. 89

Exercise


                                                        Section A (Objective)
                 A.  Tick (✓) the correct option.
                     1.  Which of these is not a type of statement in the Java language?

                       a. if statement                                  b. if … else statement

                       c. if … else… if statement                       d. if…elif…if statement

                     2.  Which of the following statements is used to execute either of the blocks of statements from if or
                        else statements?

                       a. if…else                                       b. if

                       c. switch                                        d. while

                     3.  Which of these statements is used as the substitute for the switch statement?
                       a. if…else ladder                                b. if ladder


                       c. do-while                                      d. None of these

                     4.  Which of the following keywords is/are used with the switch statement?
                       a. break                                         b. default


                       c. Both a and b                                  d. None of these

                     5.  Which of the following statements repeatedly executes a set of statements for a given number of
                        times?
                       a. break                                         b. for

                       c. continue                                      d. if…else…if

                     6.  Which of the following is an example of a runtime error?

                       a. Missing semicolon at the end of the line

                       b. Adding an extra bracket at the end of the class or function

                       c. Dividing a number by zero

                       d. Using (*) sign in place of (+) sign

                 B.  Fill in the blanks using the words given below.

                                            Hints: break, do-while, case, while, conditional


                     1.  The ................ loop executes the statements at least once, whether the given condition returns true
                        or false.
                     2.  The ........................ loop checks the condition first before executing the statements written inside its
                        body.


                                                                                                                  87
                                                              Conditional, Looping and Jumping Statements in Java
   84   85   86   87   88   89   90   91   92   93   94