Preview

16 - Using the Maths Classes

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

  calculations

  methods

  formulas

  operators

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

  bytemath.class

  java.lang.Math

  mathjavac.class

  javamatheo.class

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

  mathjavac.class

  bytemath.class

  It will return the Absolute value of the given value.

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

 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 returns the value of first argument raised to the power to second argument.

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

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

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

   It returns the Largest of two values.

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

  It will return the Absolute value of the given value.

 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 is used to round of the decimal numbers to the nearest value.

   It returns the Largest of two values.

  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);

  FALSE

  TRUE

 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()