1. Which of the following pairs of declarations will cause an error message?
    • double x = 14.7;
      int y = x;
    • double x = 14.7;
      int y = (int) x;
    • int x = 14;
      double y = x;
    • None
    • I only
    • II only
    • III only
    • I and III only
  2. What value is stored in result if

    int result = 13 - 3 * 6 / 4 % 3;

    • −5
    • 0
    • 13
    • −1
    • 12
  3. Refer to the following code fragment:
    double answer = 13 / 5;
    Console.WriteLine("13 / 5 = " + answer);

    The output is

    13 / 5 = 2.0

    The programmer intends the output to be

    13 / 5 = 2.6

    Which of the following replacements for the first line of code will not fix the problem?

    • double answer = (double) 13 / 5;
    • double answer = 13 / (double) 5;
    • double answer = 13.0 / 5;
    • double answer = 13 / 5.0;
    • double answer = (double) (13 / 5);
  4. Suppose that addition and subtraction had higher precedence than multiplication and division. Then the expression

    2 + 3 * 12 / 7 - 4 + 8

    would evaluate to which of the following?

    • 11
    • 12
    • 5
    • 9
    • −4