Home / Java Programming / Java.lang Class :: Pointing out the correct statements

Java Programming :: Java.lang Class

  1. Which statement is true given the following?

    Double d = Math.random();

  2. A.
    0.0 < d <= 1.0
    B.
    0.0 <= d < 1.0
    C.
    Compilation fail
    D.
    Cannot say.

  3. Which two statements are true about wrapper or String classes?

    1. If x and y refer to instances of different wrapper classes, then the fragment x.equals(y) will cause a compiler failure.
    2. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true.
    3. If x and y are String references and if x.equals(y) is true, then x == y is true.
    4. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true.
    5. If x and y are String references and x == y is true, then y.equals(x) will be true.

  4. A.
    1 and 2
    B.
    2 and 3
    C.
    3 and 4
    D.
    4 and 5

  5. Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d?

  6. A.
    (int)Math.min(d);
    B.
    (int)Math.max(d);
    C.
    (int)Math.abs(d);
    D.
    (int)Math.floor(d);

  7. What two statements are true about the result obtained from calling Math.random()?

    1. The result is less than 0.0.
    2. The result is greater than or equal to 0.0..
    3. The result is less than 1.0.
    4. The result is greater than 1.0.
    5. The result is greater than or equal to 1.0.

  8. A.
    1 and 2
    B.
    2 and 3
    C.
    3 and 4
    D.
    4 and 5