Home / Java Programming / Java.lang Class :: General Questions

Java Programming :: Java.lang Class

  1. What is the value of "d" after this line of code has been executed?

    double d = Math.round ( 2.5 + Math.random() );

  2. A.
    2
    B.
    3
    C.
    4
    D.
    2.5

  3. Which of the following would compile without error?

  4. A.
    int a = Math.abs(-5);
    B.
    int b = Math.abs(5.0);
    C.
    int c = Math.abs(5.5F);
    D.
    int d = Math.abs(5L);

  5. Which of the following are valid calls to Math.max?

    1. Math.max(1,4)
    2. Math.max(2.3, 5)
    3. Math.max(1, 3, 5, 7)
    4. Math.max(-1.5, -2.8f)

  6. A.
    1, 2 and 4
    B.
    2, 3 and 4
    C.
    1, 2 and 3
    D.
    3 and 4

  7. public class Myfile  {      public static void main (String[] args)      {         String biz = args[1];          String baz = args[2];          String rip = args[3];          System.out.println("Arg is " + rip);      }  } 
    Select how you would start the program to cause it to print: Arg is 2

  8. A.
    java Myfile 222
    B.
    java Myfile 1 2 2 3 4
    C.
    java Myfile 1 3 2 2
    D.
    java Myfile 0 1 2 3