Foundation to Java Programming - The While Loop


Available Answers

  1. 1.

    Fill in the blanks.

    1. The ___________________ loop is preferred when the number of iteration is fixed.
    2. The ___________________ loop is preferred more for extraction of digits.
    3. The loop that iterates continuously is called ___________________ loop.
    4. The ___________________ separator marks the end of condition in a do-while loop.
    5. Braces are optional if there is only ___________________ statement to be executed inside a while loop.
  2. 2.

    State whether the following statements are True (T) or False (F).

    1. The 'for' loop is more preferable in case you need to extract a digit.
    2. The do-while loop is an entry controlled loop.
    3. If the test-expression is true in a do-while loop, the loop continues.
    4. The initialization and updation are in the same line in a while loop.
    5. Both while and do-while are used if the number of iterations is not fixed.
  3. 3.

    Give the output of the following program fragment (a):

    class Loop1
    {
        public static void main()
        {
         int b;
         b=1;
            while (b<=19)
            {
               System.out.println(b+" ");
               b+=2;
            }
        }
    }
  4. 4.

    Write the general syntax of 'while' loop.

  5. 5.

    Write a program to input an integer and find the sum of its digits.

  6. 6.

    Write a program to input an integer and find the product of its digits.

16 more answer(s) available.

Please login to post your comments.