Mathematical library functions Mathematical library functions Basics of Math Library, Rounding Functions, Trigonometric Functions, Logarithmic and Exponential Functions, Absolute Value and Random Numbers, Complex Applications, Combination of Math Functions 1 / 10 What is the result of the following code snippet? System.out.println(Math.pow(2, 3)); 6 8 9 2.3 Math.pow(2, 3) calculates 232^323, which equals 8 Math.pow(2, 3) calculates 232^323, which equals 8 2 / 10 Which of the following methods always rounds a number down to the nearest integer? Math.ceil() Math.floor() Math.round() Math.trunc() 3 / 10 What will the following code output? double angle = Math.PI / 4; System.out.println(Math.sin(angle)); 1.0 0.5 0.0 0.707 sin(π/4)=22≈0.707 sin(π/4)=22≈0.707 4 / 10 What will the following code print? System.out.println(Math.log(Math.E)); 1.0 0.0 2.718 Compilation Error 5 / 10 Which method is used to calculate the base-10 logarithm of a number in Java? Math.ln() Math.logBase10() Math.log10() Math.exp() 6 / 10 What is the result of the following code snippet? System.out.println(Math.abs(-25.5)); 25.5 -25.5 0 Compilation Error The Math.abs() method returns the absolute value of a number, which removes the negative sign The Math.abs() method returns the absolute value of a number, which removes the negative sign 7 / 10 What is the range of the random number generated by Math.random() 0.0 to 1.0 (inclusive) 0 to 1 (inclusive) 1 to 10 (exclusive) 0.0 to 1.0 (exclusive) Math.random() generates a double value in the range [0.0, 1.0). Math.random() generates a double value in the range [0.0, 1.0). 8 / 10 What will the following code print? double x = -2.7; System.out.println(Math.ceil(x) + ” ” + Math.floor(x)); -2.0 -3.0 -3.0 -2.0 2.0 3.0 Runtime Error Math.ceil() rounds up to the nearest integer (−2.7→−2.0-2.7 \to -2.0−2.7→−2.0), and Math.floor() rounds down (−2.7→−3.0-2.7 \to -3.0−2.7→−3.0) Math.ceil() rounds up to the nearest integer (−2.7→−2.0-2.7 \to -2.0−2.7→−2.0), and Math.floor() rounds down (−2.7→−3.0-2.7 \to -3.0−2.7→−3.0) 9 / 10 What will the following code output? double result = Math.pow(Math.sqrt(16), 3); System.out.println(result); 256.0 128.0 64.0 16.0 10 / 10 What is the result of this program? System.out.println(Math.max(Math.min(10, 20), Math.min(5, 15))); 5 10 12 15 Math.min(10, 20) = 10, Math.min(5, 15) = 5. Then Math.max(10, 5) = 15 Math.min(10, 20) = 10, Math.min(5, 15) = 5. Then Math.max(10, 5) = 15 Your score is By WordPress Quiz plugin