Preview

16 - Using the Maths Classes

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

  methods

  calculations

  operators

  formulas

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

  bytemath.class

  javamatheo.class

  mathjavac.class

  java.lang.Math

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

  It will return the Absolute value of the given value.

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

  bytemath.class

  mathjavac.class

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

   It returns the Largest of two values.

  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.

 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 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.

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

  TRUE

  FALSE

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

  math.rand()

  rand():

   random() ;

  randomNum.math()