Math Class - AP Computer Science A

  1. What is the return value of Math.addExact(2147483647, 1)?
    Throws ArithmeticException. Integer overflow causes ArithmeticException to be thrown.
  2. What is the return value of Math.min(-2, -5)?
    -5. Returns the smaller of the two values.
  3. What is Math.E approximately equal to?
    2.718281828459045. The mathematical constant e (Euler's number).
  4. What is the result of Math.hypot(3, 4)?
    5.0. Calculates 32+42=25=5\sqrt{3^2 + 4^2} = \sqrt{25} = 5.
  5. What does Math.subtractExact(-2147483648, 1) return?
    Throws ArithmeticException. Integer underflow causes ArithmeticException to be thrown.
  6. What is Math.PI approximately equal to?
    3.141592653589793. The mathematical constant π\pi (pi).
  7. What does Math.floor(3.7) return?
    3.0. Rounds down to the nearest integer value.
  8. What does Math.toRadians(180) return?
    PI1\frac{\text{PI}}{1} radians. Converts 180 degrees to radians using π\pi radians per 180 degrees.
  9. State the formula for calculating the hypotenuse using Math methods.
    Math.sqrt(a2+b2)Math.sqrt(a^2 + b^2). Uses the Pythagorean theorem for right triangle hypotenuse.
  10. What is the result of Math.ceil(4.2)?
    5.0. Rounds up to the nearest integer value.
  11. What does Math.abs(-5) return?
    5. Returns the absolute value, removing the negative sign.
  12. State the result of Math.max(3, 7).
    7. Returns the larger of the two values.
  13. What does Math.sqrt(16) return?
    4.0. Returns the square root of 16, which is 4.
  14. What is the result of Math.pow(2, 3)?
    8. Calculates 23=2×2×22^3 = 2 \times 2 \times 2.
  15. What does Math.round(4.5) return?
    5. Rounds to the nearest integer using banker's rounding.
  16. What is the result of Math.random() * 10?
    A random double between 0.0 and 10.0. Multiplies random value by 10 to scale the range.

Study these flashcards