Answers to Self-Review Exercises (Sections C.1–C.13)

  1. C.1

    1. sequence, selection, repetition.

    2. ifelse.

    3. sentinel, signal, flag or dummy.

    4. strongly typed.

    5. prefixed.

  2. C.2

    1. False. A set of statements contained within a pair of braces ({ and }) is called a block.

    2. False. A repetition statement specifies that an action is to be repeated while some condition remains true.

    3. True.

    4. True.

    5. False. Instance variables of type boolean are given the value false by default.

  3. C.3

    1. z = x++ + y;

    2. 
      if ( count > 10 )
          System.out.println( "Count is greater than 10" );
      
    3. total -= --x;

    4. 
      q %= divisor;
      q = q % divisor;
      
  4. C.4

    1. 
      int sum;
      int x;
      
    2. x = 1;

    3. sum = 0;

    4. sum += x; or sum = sum + x;

    5. System.out.printf( "The sum is: %d\n", sum );

  5. C.5 product = 25, x = 6

  6. C.6

    1. Error: The ...

Get Android How to Program, 3/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.