Preview

16 - Using the Maths Classes

 1. Java Math class provides several ________ to work on math calculations like min(), max(), avg(),

  calculations

  operators

  methods

  formulas

 2. The _____ class contains various methods for performing basic numeric operations such as the logarithm, cube root, and trigonometric functions etc

  java.lang.Math

  mathjavac.class

  bytemath.class

  javamatheo.class

 3. Match the the Math Method to its corresponding description.
Math.abs()

  bytemath.class

  It is used to round of the decimal numbers to the nearest value.

  It will return the Absolute value of the given value.

  mathjavac.class

 4. Match the the Math Method to its corresponding description.
Math.max()

  It will return the Absolute value of the given value.

   It returns the Largest of two values.

  It is used to round of the decimal numbers to the nearest value.

  It returns the value of first argument raised to the power to second argument.

 5. Match the the Math Method to its corresponding description.
Math.round()

  It will return the Absolute value of the given value.

  It is used to round of the decimal numbers to the nearest value.

  It returns the value of first argument raised to the power to second argument.

   It returns the Largest of two values.

 6. Match the the Math Method to its corresponding description.
Math.pow()

  It returns the value of first argument raised to the power to second argument.

   It returns the Largest of two values.

  It is used to round of the decimal numbers to the nearest value.

  It will return the Absolute value of the given value.

 7. What is the output of the following code?
public class MyClass {
  public static void main(String[] args) {
    System.out.println(Math.max(5, 10));  
  }
}

 8. The output of the following code is 4.00
public class MyClass {
  public static void main(String[] args) {
    System.out.println(Math.abs(-4.7));  
  }
}

  TRUE

  FALSE

 9. Fill in the blanks to find the highest value of x and y.
int x = 5;
int y = 10;
Math._____(x, y);

 10. The following code would accurately find the square root of x.
int x = 16;
sqrt(x);

  TRUE

  FALSE

 11. Use the correct method to return a random number between 0 (inclusive), and 1 (exclusive). What needs to be added?
Math.

  rand():

   random() ;

  randomNum.math()

  math.rand()