Sample questions for test 1

  1. (a) Give one example of a coding style convention used in the textbook.
    (b) When writing a program, why should you adhere to this coding style convention?
  2. Java provides four different addition operators. All four are denoted by +. One takes two ints and returns an int. There are also addition operators for longs, floats and doubles. Similarly, Java provides four different subtraction, multiplication and division operators. Consider the following code snippet.
    float f = 1.0f;
    double d = 1.0E300;
    char c = 'a';
    output.println(f / d - d + c * f);
    
    Give the order in which the operations are performed (For example, first an addition of floats, second a multiplication of doubles, etc).