Exercises
I. Choose the correct answer:
1. Which of the following is false to find square of a number?
(b) a*a
(a) Math.pow(a,2)
(c) Math.sqrt(a,2)
(d) All of the above
2. What type of value is returned by Math.sqrt()?
(a) int
(b) float
(c) double (d) All
3. Which of the following syntax is true to find the square root of a number
(a) sqrt(a)
(b) Math.sqrt(a)
(c) Squareroot(a)
(d) None
4. Name the class that is used for different Mathematical functions. [ICSE-2007
(a) Java.Math (b) Java.Power (c) Java.Sqrt (d) None
5. Give the output of the Math.abs(x); when x = -9.99
[ICSE-2008)
(a) -9.99
(b) 9.99
(c) 0.99
(d) None
6. Give the output of Math.sqrt(x); when x = 9.0
(ICSE-2008)
(a) 3
(b) 3.0
(c) 3.00
(d) all
II. /Predict the output:
Answers
Answered by
3
because the find to square is not the formmula so All of the above is wrong
Answered by
21
Answer:
1. c
2. c
3. b
4. a
5. b
6. a
Explanation:
1. Math.sqrt would return the square root of the number instead of the square
2. 'double' as negative values are considered as NaN( Not a Number)
3. Math.sqrt is the right syntax
4. Java.Math is the only valid class
5. As the function gives the absolute value it's answer is 9.99
6. Answer is of 'double' type for Math.sqrt, thus 3
Similar questions