Math Class - AP Computer Science A
- What is the return value of Math.addExact(2147483647, 1)?
- Throws ArithmeticException. Integer overflow causes ArithmeticException to be thrown.
- What is the return value of Math.min(-2, -5)?
- -5. Returns the smaller of the two values.
- What is Math.E approximately equal to?
- 2.718281828459045. The mathematical constant e (Euler's number).
- What is the result of Math.hypot(3, 4)?
- 5.0. Calculates .
- What does Math.subtractExact(-2147483648, 1) return?
- Throws ArithmeticException. Integer underflow causes ArithmeticException to be thrown.
- What is Math.PI approximately equal to?
- 3.141592653589793. The mathematical constant (pi).
- What does Math.floor(3.7) return?
- 3.0. Rounds down to the nearest integer value.
- What does Math.toRadians(180) return?
- radians. Converts 180 degrees to radians using radians per 180 degrees.
- State the formula for calculating the hypotenuse using Math methods.
- . Uses the Pythagorean theorem for right triangle hypotenuse.
- What is the result of Math.ceil(4.2)?
- 5.0. Rounds up to the nearest integer value.
- What does Math.abs(-5) return?
- 5. Returns the absolute value, removing the negative sign.
- State the result of Math.max(3, 7).
- 7. Returns the larger of the two values.
- What does Math.sqrt(16) return?
- 4.0. Returns the square root of 16, which is 4.
- What is the result of Math.pow(2, 3)?
- 8. Calculates .
- What does Math.round(4.5) return?
- 5. Rounds to the nearest integer using banker's rounding.
- 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.