ICSE · Class 9 · Computer Applications
Class 9 Mathematical Library Methods Mock Test (ICSE)
6 practice questions from Mathematical Library Methods, in the style of your board paper, each with a worked answer and the marks for every step. Then take a full chapter test on paper, snap the pages and get every step marked.
Topics in Mathematical Library Methods
- Math.pow and Math.sqrt
- Math.abs, Math.max and Math.min
- Math.round, Math.ceil and Math.floor
- Math.random
- Using Math methods in expressions
Mathematical Library Methods practice questions with answers
- Q1Multiple choice1 markWhat is the output of the expression `int x = (int)Math.max(Math.min(10, 15), Math.abs(-12));`?
- (a)
- (b)
- (c)
- (d)
Show answer and step marks
- Correct option: (a) +1
Answer: (a) - Q2Multiple choice1 markA square sports ground has an area of 144 m². Which Java expression gives the length of one side in metres?
- (a)
- (b)
- (c)
- (d)
Show answer and step marks
- Correct option: (a) +1
Answer: (a) - Q3Short answer3 marksAn orchard packs fruit into boxes that each hold 10 fruit. A program stores the number of boxes needed as shown below. int fruit = 43; double boxes = fruit / 10.0; (a) Find the value of Math.floor(boxes). [1] (b) Find the value of Math.ceil(boxes). [1] (c) Find the value of Math.round(boxes). [1]
Show answer and step marks
- boxes = 43 / 10.0 = 4.3, so Math.floor(4.3) gives the largest integer not greater than 4.3, which is 4.+1
- Math.ceil(4.3) gives the smallest integer not less than 4.3, which is 5.+1
- Math.round(4.3) rounds to the nearest integer, and 0.3 is less than 0.5, so the value is 4.+1
Answer: (a) 4; (b) 5; (c) 4 - Q4Short answer3 marksA dice game program contains the statement int r = (int)(Math.random()*6)+1; to simulate the throw of a dice. (a) State the range of values that Math.random() returns. [1] (b) State the set of values that the variable r can take. [1] (c) State the value of r when Math.random() returns 0.99. [1]
Show answer and step marks
- Math.random() returns a double x with +1
- Math.random()*6 lies between 0.0 and less than 6.0; the cast keeps the integer part 0 to 5, and adding 1 gives r from 1 to 6+1
- ; cast gives 5; adding 1 gives r = 6+1
Answer: (a) (0.0 included, 1.0 excluded); (b) 1, 2, 3, 4, 5, 6; (c) 6 - Q5Long answer4 marksWrite a Java program to accept the lengths of the three sides of a triangle (, , and ) as double values using the Scanner class. Calculate and display the area of the triangle using Heron's formula: where . Use the appropriate Math library method in your expression.
Show answer and step marks
- Correct import statement (`import java.util.Scanner;`), class declaration, and `main` method setup with `Scanner` initialization.+1
- Correctly reading three double values for sides and computing the semi-perimeter .+1
- Using `Math.` to evaluate the Heron's formula expression `Math.`.+1
- Printing the computed area cleanly using `System.out.println()`.+1
Answer: import java.util.Scanner; public class HeronArea { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter the three sides: "); double a = sc.nextDouble(); double b = sc.nextDouble(); double c = sc.nextDouble(); double s = (a + b + c) / 2.0; double area = Math.; System.out.println("Area of the triangle = " + area); } } (The sides are assumed to form a valid triangle.) - Q6Long answer4 marksWrite a program in Java using the `Scanner` class to accept the coordinates of a point as `double` values. Calculate and display its distance from the origin using the formula: Use appropriate `Math` library methods for your calculations.
Show answer and step marks
- Importing java.util.Scanner and setting up the class and main method structure.+1
- Accepting input for x and y coordinates correctly as double values using Scanner.+1
- Applying the mathematical expression using Math.pow() and Math. methods.+1
- Displaying the calculated distance with an appropriate output message.+1
Answer: import java.util.Scanner; public class Distance { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter x and y: "); double x = sc.nextDouble(); double y = sc.nextDouble(); double d = Math.; System.out.println("Distance from the origin = " + d); } }
Take a full Mathematical Library Methods test
PrepitUp writes a fresh paper on this chapter at the length you pick. Write it on paper with a timer, photograph the pages, and see the marks for every step and what to practise next.
- 15 min10 marks
- 30 min20 marks
- 1.5 hr40 marks
- 3 hr80 marks
Get your Mathematical Library Methods answers marked
Sign in, pick this chapter and a length, write the test on paper and get every step marked.
Sign in to take this test