Review Questions

graphics/rq_icon.gif

3.4

Which of the following expressions will be evaluated using floating-point arithmetic?

Select the three correct answers.

  1. 2.0 * 3.0

  2. 2 * 3

  3. 2/3 + 5/7

  4. 2.4 + 1.6

  5. 0x10 * 1L * 300.0

3.5

What is the value of the expression (1 / 2 + 3 / 2 + 0.1)?

Select the one correct answer.

  1. 1

  2. 1.1

  3. 1.6

  4. 2

  5. 2.1

3.6

What will be the result of attempting to compile and run the following program?

public class Integers {
    public static void main(String[] args) {
        System.out.println(0x10 + 10 + 010);
    }
}

Select the one correct answer.

  1. The program will not compile. The compiler will complain about the expression 0x10 + 10 + 010.

  2. When run, the program will print 28.

  3. When run, the program will print 30.

  4. When run, the program will print 34.

  5. When run, the program will print 36.

  6. When run, the program will print 101010.

3.7

Which of the following expressions are valid?

Select the three correct answers.

  1. (- 1 -)

  2. (+ + 1)

  3. (+-+-+-1)

  4. (--1)

  5. (1 * * 1)

  6. (- -1)

3.8

What is the value of evaluating the following expression (- -1-3 * 10 / 5-1)?

Select the one correct answer.

  1. ?8

  2. ?6

  3. 7

  4. 8

  5. 10

  6. None of the above.

3.9

Which of these assignments are valid?

Select the four correct answers.

  1. short s = 12;

  2. long l = 012;

  3. int other = (int) true;

  4. float f = -123;

  5. double d = 0x12345678;



     
    ASPTreeView.com
     
    Evaluation has БЕѕexpired.
    Info...