Page 112 - CA_Blue( J )_Class10
P. 112
Ans. a. Math.sqrt(Math.pow(a,2) + Math.pow(c,2))
b. Math.pow(a,1/n)
c. x= (-b + Math.sqrt(Math.pow(b,2) - (4 * a *c)))/(2*a)
d. Math.sin(a)*Math.cos(b) + Math.cos(a)*Math.sin(b)
2
9. Write an expression in Java for |x +2xy|.
Ans. Math.abs(Math.pow(x,2) + 2*x*y)
10. Write the data type of the output given by the following methods:
a. Math.ceil( ) b. Math.pow( )
c. Math.abs( ) d. Math.sqrt( )
e. Math.round( )
Ans. a. double b. double
c. same as the data types of the arguments d. double
e. int
D. Assertion and Reasoning based questions.
The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting the
appropriate option given below:
a. Both A and R are true, and R is the correct explanation of A.
b. Both A and R are true, but R is not the correct explanation of A.
c. A is true, but R is false.
d. A is false, but R is true.
1. Assertion (A): The Math.abs() method in Java returns the absolute value of a given number.
Reason (R): The Math.abs() method only works for integer values in Java.
2. Assertion (A): The Math.round() method rounds a floating-point number to the nearest integer.
Reason (R): The Math.round() method uses the "round half up" rule, where .5 and above are rounded up to the nearest integer.
3. Assertion (A): The Math.random() method generates a random double value between 0.0 (inclusive) and 1.0 (exclusive).
Reason (R): The Math.random() method can generate a negative random value.
Ans. 1. c 2. a 3. c
21 st
E. Case-based questions. Century #Experiential Learning
Skills
1. Ram is working on a navigation system for a new mobile app. He needs to calculate the distance between two points on a map.
The coordinates of the two points are given as (x1, y1) and (x2, y2). John decides to use the distance formula:
Which Java methods from the Math class should John use to implement this calculation?
a. Math.pow() and Math.sqrt() b. Math.abs() and Math.ceil()
c. Math.floor() and Math.log() d. Math.max() and Math.min()
2. Debolina is developing a game that involves rolling a six-sided die. To simulate the die roll, she needs to generate a random
number between 1 and 6. Which of the following code snippets correctly achieves this using Java's Math library?
a. int roll = (int)(Math.random() * 6) + 1; b. int roll = Math.random() * 6;
c. int roll = Math.floor(Math.random() * 6) + 1; d. int roll = (int)(Math.random() * 5) + 1;
Ans. 1. a 2. a
Unsolved Questions
A. Tick ( ) the correct answer.
1. Which of the following is the output of the Math.pow(Math.sqrt(4),2) method?
a. 2.0 b. 4.0
c. 8.0 d. None of these
2. How many arguments are required to use the Math.min( ) method?
a. 1 b. 2
c. 3 d. 4
110110 Touchpad Computer Applications-X

