Page 153 - CA_Blue( J )_Class9
P. 153
Let’s Revisit
There are two types of methods in Java: user-defined methods and built-in/library methods.
To use mathematical methods in programs, we need to use the “Math” class, which resides in the “java.lang”
package.
To use mathematical functions, the syntax is: “Math.function_name(arguments);”..
MIND DRILL
Solved Questions
A. Tick ( ) the correct answer.
1. One advantage of using a method ………………….
a. Cannot be compiled b. Cannot be used
c. Can makes programs tough d. Can be reused
2. Which of the following methods are already defined in the Java compiler?
a. User defined b. Library
c. Both a and b d. None of these
3. Which of the following classes is required to use mathematical methods in Java?
a. Util b. InputStreamReader
c. Math d. Scanner
4. Which type of value does Math.abs() method return?
a. Negative b. Positive
c. Infinite d. Fixed
5. Which type of value does Math.pow() method return?
a. int b. double
c. char d. float
6. What will be the output of the following code fragment?
int x = 5, y = 10;
System.out.println(Math.max(x, y));
a. 50 b. 5.0
c. 10 d. 10.0
7. Which type of value does Math.max(double, int) return?
a. int b. float
c. double d. None of these
8. Which of the following does double a = Math.ceil(7.343); return?
a. 7.0 b. -7.0
c. 8.0 d. -8.0
9. Math.log works on ………………… numbers only.
a. Negative b. Odd
c. Even d. Positive
Mathematical Library Methods 151

