0% found this document useful (0 votes)
19 views

Chapter 7_ Mathematical Library Methods _ Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java _ KnowledgeBoat

Chapter 7 of the document covers Mathematical Library Methods in Java, providing multiple choice and assignment questions related to various mathematical functions such as Math.abs(), Math.sqrt(), and Math.random(). It includes explanations of these methods, their outputs, and examples of how to use them in Java programming. The chapter aims to enhance understanding of mathematical operations in Java for Class 10 ICSE students.

Uploaded by

adithi.r785
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Chapter 7_ Mathematical Library Methods _ Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java _ KnowledgeBoat

Chapter 7 of the document covers Mathematical Library Methods in Java, providing multiple choice and assignment questions related to various mathematical functions such as Math.abs(), Math.sqrt(), and Math.random(). It includes explanations of these methods, their outputs, and examples of how to use them in Java programming. The chapter aims to enhance understanding of mathematical operations in Java for Class 10 ICSE students.

Uploaded by

adithi.r785
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with

puter Applications with BlueJ Java | K…

STUDY MATERIAL LOGIN JOIN NOW

Home / Class 10 - Logix Kips ICSE Computer Applications with BlueJ / Mathematical Library Methods

CONTENTS
Chapter 7
Search by lesson title
Mathematical Library Methods Multiple Choice Questions

Chapter 1 Assignment Questions


Class 10 - Logix Kips ICSE Computer Applications with BlueJ
Object Oriented Programming Concepts

Chapter 2
Introduction to Java

Chapter 3

Up to 50% Off Courses &


Values and Data Types

Chapter 4
Operators in Java
Certs
Chapter 5
User-Defined Methods

Chapter 6
Input in Java

Chapter 7
Linux Foundation Training Sign Up
Mathematical Library Methods

Chapter 8
Conditional Constructs in Java
Multiple Choice Questions
Chapter 9
Iterative Constructs in Java
Question 1
Chapter 10
Nested for loops
What will be the output of Math.cbrt(-125)?
Chapter 11
Constructors
1. 5.0
Chapter 12
Library Classes
2. 0.0

Chapter 13
3. -5.0 ✓
Encapsulation and Inheritance
4. error — can't use Math.cbrt() on a negative number
Chapter 14
Arrays
Question 2
Chapter 15
String Handling
Which Java package includes the Math class?

1. java.io
2. java.lang ✓
3. java.util
4. java.sys

Question 3

Give the output of Math.sqrt(x); when x = 9.0

1. 3
2. 3.0 ✓
3. 3.00
4. All of these

Question 4

Give the output of Math.ceil(-0.6).

1. -1.6
2. -1.5
3. -1.0

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 1/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

4. -0.0 ✓

Question 5

Give the output of Math.ceil(-46.6).

1. -46.6
2. -46.5
3. -47.0
4. -46.0 ✓

Question 6

Give the output of Math.abs(x); when x = -9.99

1. -9.99
2. 9.99 ✓
3. 0.99
4. None of these

Question 7

Which of the following is a method to find the square root of a


number?

1. FindSquareroot(x)
2. Sqrt(x)
3. Math.Square(x)
4. Math.sqrt(x) ✓

Question 8

What will be the output of Math.pow(3, 0)?

1. 0.0
2. 1.0 ✓
3. 3.0
4. -1.0

Question 9

Math.random() returns a double value r such that ...........

1. 0.0 <= r < 1.0 ✓


2. 0.0 <= r <= 1.0
3. 0.0 < r <= 1.0
4. 0.0 < r < 1.0

Question 10

What will be the output of Math.floor(-20.10)?

1. -20.0
2. -21.0 ✓
3. 20

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 2/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

4. 21

Question 11

What will be the output of Math.round(0.5)?

1. 0.0
2. 0
3. 1 ✓
4. 1.0

Question 12

What will be the output of Math.abs(-0)?

1. 0.0
2. 0 ✓
3. -0
4. +0

Question 13

Given the following statements:

int min = 1, max = 10;


int range = max - min + 1;
int num = (int) (range * Math.random() + min);

The value of num will be in integer such that ...........

1. 1 <= num <= 10 ✓


2. 1 <= num < 10
3. 1 < num <= 10
4. 1 < num < 10
Assignment Questions

Question 1

How do user-defined methods differ from library methods?

Answer

A user-defined method is a method defined by the user whereas


library methods or built-in methods are the methods created by the
developers of Java which are available in the form of packages.

Question 2

Distinguish between Math.ceil() and Math.floor() methods.

Answer

Math.ceil( ) Math.floor( )

Returns the smallest double Returns the largest double


value that is greater than or value that is less than or
equal to the argument and is equal to the argument and is

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 3/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

Math.ceil( ) Math.floor( )

equal to a mathematical equal to a mathematical


integer integer.

double a = Math.ceil(65.5); double b = Math.floor(65.5);


In this example, a will be In this example, b will be
assigned the value of 66.0 as assigned the value of 65.0 as
it is the smallest integer it is the largest integer smaller
greater than 65.5. than 65.5.

Question 3

What is wrong with the following statements? Explain.

i. result = (5/10) * Math.sqrt( a );

Answer

(5/10) will lead to integer division as both numerator and


denominator are integers. So result of (5/10) will be 0 instead of
0.5 and the entire expression will always result in 0.

ii. result = math.sqrt(b * b - 4 * a * c) / ( 2 * a );

Answer

math should be written as Math. As Java is case-sensitive so it


treats math and Math differently.

Question 4

Explain the following Math functions in Java:

i. Math.abs()

Answer

Returns the absolute value of its argument. Its return type is same
as the type of its arguments. For example, Math.abs(-5) will return
5.

ii. Math.sqrt()

Answer

Returns the square root of its argument as a double value. For


example, Math.sqrt(25) will return 5.0.

iii. Math.cbrt()

Answer

Returns the cube root of its argument as a double value. For


example, Math.cbrt(27) will return 3.0.

iv. Math.random()

Answer

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 4/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

Returns a positive double value, greater than or equal to 0.0 and


less than 1.0.

v. Math.round()

Answer

Rounds off its argument to the nearest mathematical integer and


returns its value as an int or long type. If argument is float, return
type is int, if argument is double, return type is long. At mid-point, it
returns the higher integer. For example, Math.round(2.5) will return
3.

vi. Math.ceil()

Answer

Returns the smallest double value that is greater than or equal to


the argument and is equal to a mathematical integer. For example,
Math.ceil(65.5) will return 66.0.

Question 5

Write Java expressions for the following:

i. The square root of a + 5b3

Answer

Math.sqrt(a + 5 * Math.pow(b, 3))

ii. The cube root of x3 + y3 + z3

Answer

Math.cbrt(x*x*x + y*y*y + z*z*z);

iii. The square root of b2 + 4ac

Answer

Math.sqrt(b * b + 4 * a * c)

Question 6

Write the following as Java expressions:

i. 3
x2 + 5y 3 ​

Answer

Math.cbrt(x * x + 5 * y * y * y)

ii. ∣x + y∣

Answer

Math.abs(x + y)

iii. ∣x3 + y 2 − 2xy∣

Answer
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 5/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

Math.abs(Math.pow(x, 3) + Math.pow(y, 2) - 2*x*y)


π 4
iv. (z − 2π)
6

Answer

Math.PI / 6*(Math.pow(z, 4) - 2*Math.PI)


3
v. z2 − π ​

Answer

Math.cbrt(z*z - Math.PI)

vi. 4
x3 − y 3 ​

Answer

Math.pow(x*x*x - y*y*y, 1/4)

amount ∗ rate
vii.
1

1−
(1 + rate)n

Answer

(amount*rate) / (1 - (1 / Math.pow(1+rate, n)))

(−b + b2 − 4ac)
viii.

2a

Answer

(-b + Math.sqrt(b*b - 4*a*c)) / (2*a)

4 1 R2
ix. −
4C 2
​ ​ ​

LC
Answer

Math.pow((1 / L*C) - ((R*R)/(4*C*C)), 1/4)

Question 7

Write valid statements for the following in Java:

i. Print the rounded off value of 14.49

Answer

System.out.println(Math.round(14.49));

ii. Print the absolute value of -0.09

Answer

System.out.println(Math.abs(-0.09));

iii. Print the largest of -67 and -50

Answer

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 6/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

System.out.println(Math.max(-67, -50));

iv. Print the smallest of -56 and -57.4

Answer

System.out.println(Math.min(-56, -57.4));

v. Print a random integer between 25 and 35

Answer

int range = 35 - 25 + 1;
int num = (int)(range * Math.random() + 25);
System.out.println(num);

vi. Print 47.5 raised to the power 6.3

Answer

System.out.println(Math.pow(47.5, 6.3));

vii. Print minimum of -4, -7

Answer

System.out.println(Math.min(-4, -7));

Question 8

Write a program in Java to find the maximum of three numbers


using Math.max() method.

Answer

import java.util.Scanner;

public class KboatGreatestNumber


{
public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter First Number: ");


int a = in.nextInt();
System.out.print("Enter Second Number: ");
int b = in.nextInt();
System.out.print("Enter Third Number: ");
int c = in.nextInt();

int g = Math.max(a, b);


g = Math.max(g, c);

System.out.println("Greatest Number = " + g);


}
}

Output

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 7/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

Question 9

Write a program to print:

i. x to the power y

ii. the square root of y

The values of x and y are 81 and 3, respectively.

Answer

public class KboatNumber


{
public static void main(String args[]) {
int x = 81;
int y = 3;

double r1 = Math.pow(x, y);


System.out.println("x to the power of y = " + r1);

double r2 = Math.sqrt(y);
System.out.println("Square root of y = " + r2);
}
}

Output

Question 10

Write a program to compute and display the value of expression:

1 1 1
2
+ 3+ 4
​ ​ ​

x y z
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 8/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

where, the values of x, y and z are entered by the user.

Answer

import java.util.Scanner;

public class KboatExpression


{
public static void main(String args[]) {

Scanner in = new Scanner(System.in);


System.out.print("Enter x: ");
int x = in.nextInt();
System.out.print("Enter y: ");
int y = in.nextInt();
System.out.print("Enter z: ");
int z = in.nextInt();

double result = 1 / Math.pow(x, 2) + 1 / Math.pow(y, 3

System.out.println("Result = " + result);


}
}

Output

Question 11

Write a program to generate random integers in the following


ranges:

i. 10 to 20 (both inclusive)
ii. 25 to 50 (both inclusive)

Answer

public class KboatRandom


{
public static void main(String args[]) {
int min = 10, max = 20;
int range = max - min + 1;
int num = (int)(range * Math.random() + min);
System.out.println("Random number in the range 10 to 2

min = 25;
max = 50;
range = max - min + 1;

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 9/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…
num = (int)(range * Math.random() + min);
System.out.println("Random number in the range 25 to 5
}
}

Output

Question 12

Write a program that accepts a number x and then prints:

x0, x1, x2, x3, x4, x5

Answer

import java.util.Scanner;

public class KboatXPower


{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter x: ");
int x = in.nextInt();
System.out.print(Math.pow(x, 0) + ", ");
System.out.print(Math.pow(x, 1) + ", ");
System.out.print(Math.pow(x, 2) + ", ");
System.out.print(Math.pow(x, 3) + ", ");
System.out.print(Math.pow(x, 4) + ", ");
System.out.print(Math.pow(x, 5));
}
}

Output

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 10/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…
Question 13

Write the equivalent Java statements for the following, by using the
mathematical functions:

i. Print the positive value of -999.

Answer

System.out.println(Math.abs(-999));

ii. Store the value -3375 in a variable and print its cube root.

Answer

int a = -3375;
System.out.println(Math.cbrt(a));

iii. Store the value 999.99 in a variable and convert it into its
closest integer that is greater than or equal to 999.99.

Answer

double a = 999.99;
System.out.println(Math.round(a));

Question 14

Write a program in Java to compute the final velocity of a vehicle


using the following formula:

v 2 = u2 + 2as

where, u = initial velocity, a = acceleration and s = distance


covered; they are entered by the user.

Answer

import java.util.Scanner;

public class KboatVelocity


{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter initial velocity: ");
double u = in.nextDouble();
System.out.print("Enter acceleration: ");
double a = in.nextDouble();
System.out.print("Enter distance covered: ");
double s = in.nextDouble();
double v = Math.sqrt(u * u + 2 * a * s);
System.out.println("Final Velocity = " + v);
}
}

Output

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 11/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…

Prev Next
Input in Java Conditional Constructs in Java

ICSE/ISC TEXTBOOK SOLUTIONS STUDYLIST COMPANY

Class - 6 Concise Biology Selina Solutions Java Pattern Programs About Us

Class - 6 Veena Bhargava Geography Solutions Java Series Programs Contact Us

Class - 6 Effective History & Civics Solutions Java Number Programs (ICSE Classes 9 / 10) Privacy Policy

Class - 6 APC Understanding Computers Solutions Java Number Programs (ISC Classes 11 / 12) Terms of Service

Class - 7 Concise Physics Selina Solutions Output Questions for Class 10 ICSE Computer Applications

Class - 7 Concise Chemistry Selina Solutions Algorithms & Flowcharts for ICSE Computers

Class - 7 Dalal Simplified Middle School Chemistry Solutions ICSE Class 8 Computers Differentiate Between the Following

Class - 7 Concise Biology Selina Solutions CBSE TEXTBOOK SOLUTIONS

Class - 7 Living Science Biology Ratna Sagar Solutions Class - 8 NCERT Science Solutions

Class - 7 Around the World Geography Solutions Class - 9 NCERT Science Solutions

Class - 7 Veena Bhargava Geography Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions

Class - 7 Effective History & Civics Solutions Class - 9 Sumita Arora Computer Code 165 Solutions

Class - 7 APC Understanding Computers Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions

Class - 8 Concise Physics Selina Solutions Class - 10 NCERT Mathematics Solutions

Class - 8 Concise Chemistry Selina Solutions Class - 10 NCERT Science Solutions

Class - 8 Dalal Simplified Middle School Chemistry Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions

Class - 8 Concise Biology Selina Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions

Class - 8 Living Science Biology Ratna Sagar Solutions Class - 10 Sumita Arora Computer Code 165 Solutions

Class - 8 Around the World Geography Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions

Class - 8 Veena Bhargava Geography Solutions Class - 11 CBSE Sumita Arora Python Solutions

Class - 8 Effective History & Civics Solutions Class - 12 CBSE Sumita Arora Python Solutions

Class - 8 APC Understanding Computers Solutions Class - 12 CBSE Preeti Arora Python Solutions

Class - 8 Kips Logix Computers Solutions Class - 12 NCERT Computer Science Solutions

Class - 9 Concise Physics Selina Solutions

Class - 9 Concise Chemistry Selina Solutions

Class - 9 Dalal Simplified ICSE Chemistry Solutions

Class - 9 Concise Biology Selina Solutions

Class - 9 Total Geography Morning Star Solutions

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 12/13
5/20/24, 1:32 PM Chapter 7: Mathematical Library Methods | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | K…
Class - 9 Veena Bhargava Geography Solutions

Class - 9 Total History & Civics Solutions

Class - 9 APC Understanding Computers Solutions

Class - 9 Kips Logix Computers Solutions

Class - 10 ML Aggarwal Mathematics Solutions

Class - 10 Concise Physics Selina Solutions

Class - 10 Concise Chemistry Selina Solutions

Class - 10 Dalal Simplified ICSE Chemistry Solutions

Class - 10 Concise Biology Selina Solutions

Class - 10 Total Geography Morning Star Solutions

Class - 10 Veena Bhargava Geography Solutions

Class - 10 Total History & Civics Solutions

Class - 10 APC Modern History & Civics Solutions

Class - 10 APC Understanding Computers Solutions

Class - 10 Sumita Arora ICSE Computers Solutions

Class - 10 Kips Logix Computers Solutions

Class - 11 APC Understanding Computers Solutions

Class - 12 APC Understanding Computers Solutions


ICSE/ISC SOLVED QUESTION PAPERS

ICSE Class 10 Computers Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Computer Applications

ICSE Class 10 Physics Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Physics

ICSE Class 10 Chemistry Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Chemistry

ICSE Class 10 Biology Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Biology

Class - 12 ISC Computer Science Solved Practical Papers

Class - 10 CBSE Computer Applications Solved Question Papers

Class - 10 CBSE Computer Applications Solved Sample Papers

Class - 10 CBSE Science Solved Question Papers

Class - 12 CBSE Computer Science Solved Question Papers

Copyright © KnowledgeBoat 2024

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/Dag71/mathematical-library-methods 13/13

You might also like