ICSE Class 10 · Computer Applications (Java) · Math library methods 2027

Math library methods for ICSE: what each one returns, and where the marks slip.

The Math library methods in ICSE Computer Applications are only ten, and every one of them is easy to call. Marks are lost on what they return: 25.0 instead of 25, -6 instead of -7, -0.0 instead of 0. This page puts all ten syllabus methods in one return-type table, then works through the output traps, the compile errors, formulas written as Java expressions and Math.random ranges. Every result was run in Java 21, and the same traps are drilled every week in our live mini batch.

Live online · all ten syllabus Math methods · 20 output traps run in Java · formulas as expressions · first class free

Start here

Courses where Math methods are practised

The ICSE Java course where the mini batch drills these return types weekly, the Class 11 and 12 Computer Science course where the same methods return in longer ISC programs, and the data structures course for students curious about how numeric code is reasoned about.

Ans. The short version

The Math library methods in ICSE Computer Applications are the static methods of Java's Math class in java.lang: pow, sqrt, cbrt, ceil, floor, round, abs, max, min and random. Most marks depend on return types. pow, sqrt, cbrt, ceil, floor and random always return double, so whole answers print with .0; round of a double returns a long with no decimal; abs, max and min return the type of their arguments after promotion. They are part of the Class 9 syllabus that the 2027 Class 10 paper revises. Modern Age Coders drills them live in a Tuesday and Wednesday mini batch in India, or one to one.

Q1. Which Math methods are in the ICSE syllabus, and what does each return?

Mathematical functions in Java Class 10: the return-type table

The syllabus lists ten methods of the Math class, all static and all in the package java.lang, which every program imports automatically. The return type column is the one to learn by heart, because it decides how the answer prints.

MethodWhat it givesReturnsExampleOutput
Math.pow(x, y)x raised to the power ydoubleMath.pow(5, 2)25.0
Math.sqrt(x)square root of xdoubleMath.sqrt(81)9.0
Math.cbrt(x)cube root of xdoubleMath.cbrt(64)4.0
Math.ceil(x)smallest whole number not less than xdoubleMath.ceil(6.1)7.0
Math.floor(x)largest whole number not more than xdoubleMath.floor(6.9)6.0
Math.round(x)nearest whole number, halves go uplong for a double, int for a floatMath.round(6.5)7
Math.abs(a)value without its signsame type as aMath.abs(-12), Math.abs(-12.5)12 12.5
Math.max(a, b)the larger of twothe wider of the two typesMath.max(8, 11), Math.max(8, 11.0)11 11.0
Math.min(a, b)the smaller of twothe wider of the two typesMath.min(-4, 9), Math.min(-4.0, 9)-4 -4.0
Math.random()a random value from 0.0 up to, but not including, 1.0doubleMath.random()varies, for example 0.6182...

Six always give double

pow, sqrt, cbrt, ceil, floor and random return double whatever you pass in. Even Math.sqrt of a perfect square prints a decimal point.

round is the odd one out

Math.round of a double returns long, of a float returns int. Either way, the answer has no .0. Halves round upwards, towards positive infinity.

Three follow their arguments

abs, max and min return int for ints and double for doubles. If one argument is int and the other double, the int is promoted first, so the result is double.

Your textbook may mention other Math methods such as sin, log or exp. The 2026-27 syllabus list we checked names only the ten above, so this page stays with those. How these methods sit beside the wrapper classes and Character methods is covered on wrapper and library classes for ICSE.

Q2. Where do Math output questions catch students?

Math.round, Math.ceil and Math.floor ICSE: output traps with answers

Nearly every wrong answer on Math comes from one of three slips: a missing or extra .0, rounding a negative half the wrong way, or doing integer division before the method sees the value. Cover the Output column and try each one.

Rounding, ceiling and floor

#CodeOutputThe trap
1System.out.println(Math.round(-6.5) + " " + Math.round(-6.51));-6 -7A half rounds up, and up from -6.5 is -6; only past the half does it go to -7
2System.out.println(Math.round(4.5) + " " + Math.round(-0.5));5 0Both halves move towards positive infinity
3System.out.println(Math.round(-1.5) + " " + Math.floor(-0.5));-1 -1.0round gives a long; floor goes down to the next whole number and gives a double
4System.out.println(Math.ceil(-0.4));-0.0Java keeps the minus sign on a zero that came from a negative number
5System.out.println(Math.floor(7.0) + " " + Math.ceil(7.0));7.0 7.0A whole number is its own floor and ceiling
6System.out.println(Math.floor(-2.2) + Math.ceil(-2.2));-5.0floor of -2.2 is -3.0 (further from zero), ceil is -2.0; two doubles are added
7System.out.println(Math.ceil(7 / 2) + " " + Math.ceil(7 / 2.0));3.0 4.07 / 2 is already 3 before ceil sees it; only 7 / 2.0 keeps the half
8System.out.println(Math.round(2.0 / 3 * 100) / 100.0);0.67The standard way to keep two decimal places: scale, round, divide by a double

Math.pow, Math.sqrt and Math.cbrt output ICSE

#CodeOutputThe trap
9System.out.println(Math.sqrt(-9));NaN (no error)No real square root exists, so Java prints NaN, "not a number"; there is no error
10System.out.println(Math.pow(-8, 1.0 / 3) + " " + Math.cbrt(-8));NaN -2.0pow cannot take a fractional power of a negative base; cbrt handles negatives
11System.out.println(Math.pow(4, 0.5) + " " + Math.pow(10, -2));2.0 0.01Power 0.5 is a square root; a negative power is a reciprocal
12System.out.println(Math.pow(0, 0) + " " + Math.sqrt(0));1.0 0.0Anything to the power 0 is 1.0 in Java, including 0
13System.out.println((int) Math.sqrt(30));5The cast cuts 5.477... down to 5; it does not round
14System.out.println(Math.sqrt(Math.pow(3, 2) + Math.pow(4, 2)));5.0Nested calls work inside out: 9.0 + 16.0, then the root
15System.out.println(Math.round(Math.sqrt(50)) + Math.round(Math.cbrt(30)));107 + 3 are two longs added as numbers, because no String comes first
16System.out.println("" + Math.round(Math.sqrt(50)) + Math.round(Math.cbrt(30)));73The empty String first turns every + into joining

abs, max and min

#CodeOutputThe trap
17System.out.println(Math.max('a', 'b'));98chars are promoted to int, so the code of 'b' is printed, not the letter
18System.out.println(Math.abs(-7 / 2) + " " + Math.abs(-7.0 / 2));3 3.5-7 / 2 is -3 in int arithmetic before abs ever runs
19System.out.println(Math.max(Math.min(15, 10), 12));12Inner call first: min gives 10, then max of 10 and 12
20System.out.println(Math.min(Math.abs(-3), -Math.abs(3)));-3The unary minus outside abs makes the second value -3
Storing a Math result in an intjavac 21
int a = Math.round(3.7);      // line 3
int b = Math.pow(2, 5);       // line 4
int c = Math.sqrt(36);        // line 5

// javac says:
E.java:3: error: incompatible types: possible lossy conversion from long to int
E.java:4: error: incompatible types: possible lossy conversion from double to int
E.java:5: error: incompatible types: possible lossy conversion from double to int

Java will not quietly shrink a long or a double into an int. This is a favourite error-finding question.

Three ways that compilerun in Java 21
int d = Math.round(3.7f);     // float in, int out
long e = Math.round(3.7);     // double in, long out
int f = (int) Math.pow(2, 5); // explicit cast
System.out.println(d + " " + e + " " + f);

// Output:
4 4 32

Pick the variable type that matches the return type, or cast on purpose. A cast truncates: (int) 4.99 is 4.

Math rows sit among every other kind of trap on ICSE Java output questions, and the error side is on ICSE Class 10 Java error finding questions.

Q3. How do you write a formula as a Java expression?

Writing mathematical expressions in Java with Math methods

A two-mark Section A part often gives a formula and asks for the Java expression. Replace each root and power with its Math method, write every multiplication sign, and add brackets wherever a fraction bar or a root covers more than one term.

FormulaJava expressionChecked withResult
distance = √((x2 − x1)² + (y2 − y1)²)Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2))(1, 2) and (4, 6)5.0
roots of ax² + bx + c = 0(-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a) and the same with −a = 1, b = −5, c = 63.0 2.0
amount = P(1 + r/100)np * Math.pow(1 + r / 100, n)P = 10000, r = 8, n = 211664.000000000002
|a − 5b| ÷ larger of a, bMath.abs(a - b * 5) / Math.max(a, b)a = 7.5, b = 20.3333333333333333
∛(2.4ab)Math.cbrt(a * b * 2.4)a = 7.5, b = 23.3019272488946267

The compound interest row is worth a second look. The true answer is 11664, but doubles store most decimals approximately, so Java prints a tiny tail. In a program, round the result to two decimal places before printing it.

The fraction that vanishedrun in Java 21
int r = 3;
// volume of a sphere, 4/3 x 22/7 x r cubed
System.out.println(4 / 3 * 22 / 7 * Math.pow(r, 3));
System.out.println(4.0 / 3 * 22 / 7 * Math.pow(r, 3));

// Output:
81.0
113.14285714285715

In the first line 4 / 3 is 1 and 22 / 7 then becomes 3, all in int arithmetic, before pow brings in a double. Writing 4.0 fixes the whole chain.

  1. Every power needs Math.pow; x^2 is not a power in Java.
  2. Every product needs *: 2ab is 2 * a * b.
  3. A fraction bar over several terms needs brackets on both top and bottom.
  4. A root over a sum needs the whole sum inside the brackets of Math.sqrt.
  5. If the formula has a fraction such as 4/3, write one of the numbers as a double.

Operator precedence, the other half of every expression question, is covered on operators in Java for ICSE Class 10.

Q4. How do you get a random whole number in a range?

Math.random in ICSE Java: whole numbers in a range, and two programs

Math.random() gives a double from 0.0 up to but not including 1.0. To get a whole number from low to high, use low + (int) (Math.random() * (high - low + 1)): multiply to stretch the range, cast to cut off the fraction, then shift it.

GoalExpressionSmallest and largest seen
A dice roll, 1 to 6(int) (Math.random() * 6) + 11 and 6 (a million runs)
A four-digit code, 1000 to 99991000 + (int) (Math.random() * 9000)1000 and 9999 (two million runs)
The bracket slip(int) Math.random() * 6 + 11 and 1 (a million runs)

The last row is the trap. The cast applies to Math.random() alone, which is always below 1.0, so it becomes 0 every time and the "dice" always shows 1. Brackets around the multiplication are what make the expression work.

Program 1. Write a program to input a decimal number and print its absolute value, the square root of its absolute value and its cube root (each to two decimal places), and its rounded value, ceiling, floor and square, using Math methods.

NumberReport.javaseven Math calls
import java.util.Scanner;
class NumberReport {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        double x = sc.nextDouble();
        double ab = Math.abs(x);
        System.out.println("Absolute value: " + ab);
        System.out.println("Square root of |x|: "
            + Math.round(Math.sqrt(ab) * 100) / 100.0);
        System.out.println("Cube root of x: "
            + Math.round(Math.cbrt(x) * 100) / 100.0);
        System.out.println("Rounded: " + Math.round(x));
        System.out.println("Ceiling: " + Math.ceil(x));
        System.out.println("Floor: " + Math.floor(x));
        System.out.println("Square: " + Math.pow(x, 2));
    }
}

sqrt gets the absolute value, because a negative input would give NaN. cbrt can take x itself.

VariableTypePurpose
scScannerreads the input
xdoublethe number entered
abdoubleabsolute value of x
Sample runJava 21
Enter a number: -18.75
Absolute value: 18.75
Square root of |x|: 4.33
Cube root of x: -2.66
Rounded: -19
Ceiling: -18.0
Floor: -19.0
Square: 351.5625

For a negative number the ceiling is the one nearer zero. -18.75 is past the half, so it rounds to -19.

Program 2. Write a program to input a positive integer. If it is a perfect square, print the number whose square it is; otherwise print the perfect squares just below and just above it and the one that is nearer.

NearSquare.javasqrt, floor, ceil, pow, abs
import java.util.Scanner;
class NearSquare {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a positive integer: ");
        int n = sc.nextInt();
        double root = Math.sqrt(n);
        if (root == Math.floor(root)) {
            System.out.println(n + " is a perfect square of " + (int) root);
        } else {
            int below = (int) Math.pow(Math.floor(root), 2);
            int above = (int) Math.pow(Math.ceil(root), 2);
            System.out.println("Squares either side: " + below + " and " + above);
            if (Math.abs(n - below) < Math.abs(above - n))
                System.out.println("Nearest: " + below);
            else
                System.out.println("Nearest: " + above);
        }
    }
}

No "equally near" branch is needed: neighbouring squares are always an odd distance apart, so a whole number can never sit exactly halfway.

Sample runsJava 21
Enter a positive integer: 196
196 is a perfect square of 14

Enter a positive integer: 90
Squares either side: 81 and 100
Nearest: 81

Enter a positive integer: 115
Squares either side: 100 and 121
Nearest: 121

root == Math.floor(root) is the perfect square test: the root has no fractional part. The casts to int are needed because pow returns double.

Perfect squares, digit powers and other number tests built on these methods are on ICSE special number programs, and series sums that lean on Math.pow are on series programs in Java for ICSE.

Q5. What does Section A ask about Math methods?

Math library methods ICSE questions with answers

These questions come in Question 1 as one-mark MCQs and in Question 2 as two-mark parts: give the output, name the return type, or write the expression. Answer each before opening it.

One-mark questions

  1. Which package contains the Math class?
    Answer java.lang, which is imported into every program automatically.
  2. What is the return type of Math.ceil(5)?
    Answer double. It returns 5.0.
  3. Give the output of Math.round(8.49) + Math.round(8.5).
    Answer 17. 8 + 9, added as long values.
  4. Which Math method returns a value from 0.0 up to but not including 1.0?
    Answer Math.random().
  5. Give the output of Math.abs(Math.floor(-3.2)).
    Answer 4.0. floor of -3.2 is -4.0, and abs of a double is a double.
  6. Which method finds the cube root: Math.sqrt, Math.cbrt or Math.pow?
    Answer Math.cbrt, which also works for negative numbers.

Two-mark questions

  1. Write the Java expression for √(3x + y²).
    Answer Math.sqrt(3 * x + Math.pow(y, 2)), or Math.sqrt(3 * x + y * y).
  2. Differentiate between Math.ceil() and Math.floor().
    Answer ceil returns the smallest whole number greater than or equal to its argument; floor returns the largest whole number less than or equal to it. Both return double: Math.ceil(4.2) is 5.0 and Math.floor(4.2) is 4.0.
  3. Give the output: double d = Math.pow(2, 10) / Math.sqrt(64); System.out.println(d);
    Answer 128.0. 1024.0 divided by 8.0.
  4. Why does int k = Math.round(9.6); not compile? Correct it.
    Answer Math.round of a double returns long, which cannot be stored in an int without a cast. Write long k = Math.round(9.6); or int k = (int) Math.round(9.6);.
  5. Write an expression for a random whole number from 10 to 20, both included.
    Answer 10 + (int) (Math.random() * 11). There are eleven values, so the multiplier is 11.

One-mark questions from every chapter in the same style are on ICSE Computer Applications MCQ questions.

Q6. How are Math methods taught in the mini batch?

Ten methods, learned until the return type is automatic

Students rarely forget what sqrt does. They forget that it returns a double. So practice is built around saying the type before the value, every time.

  1. Type first, value second

    The Tuesday 5:30 PM IST class opens with a rapid round of Math calls. For each one the student names the return type, then the printed value, and a missing .0 counts as wrong.

  2. Negative numbers on purpose

    Rounding, ceiling and floor are drilled with negative arguments and halves, because that is where the board's options are built to mislead.

  3. Formulas to expressions

    Physics and maths formulas from the student's own school books are turned into Java expressions and run in BlueJ to check the brackets.

  4. Math inside programs

    On Wednesday at 8:00 PM IST the methods appear inside full programs, such as number tests and series, written by hand and marked against the board scheme on screen.

  5. Mock papers from December

    Complete two-hour papers bring Math questions back in both sections, timed and marked like the real thing.

Math methods are Class 9 content that Class 10 revises; the rest of that revision is on Class 9 Java revision for Class 10.

Batch or personalised: you choose

Drill Math methods in the mini batch, or one to one

The return-type drills, the negative-number traps and the formula practice are the same in either format. In India, families choose the fixed evening group of up to six or a private slot; ICSE students abroad learn one to one. Billing is monthly, with no admission fee.

Option 1 · Fixed batch timings

Mini batch, Tuesday 5:30 PM and Wednesday 8 PM

₹2,999

per month, two live classes a week

  • Tuesday 5:30 PM and Wednesday 8:00 PM IST, live
  • Six ICSE Class 10 students at most
  • A return-type round at the start of every Tuesday class
  • Formulas checked in BlueJ on a shared screen
  • Math questions inside full mock papers from December
Book a free demo in this batch

Option 2 · Choose your own timing

Personalised one to one

₹4,999

per month, one private class a week, at a time set with you

  • A slot the family picks, in India or overseas
  • Practice aimed at the exact Math slips your child makes
  • School physics and maths formulas used as practice
  • Harder nested calls once the basics are secure
  • Same teachers and the same 2027 syllabus
Ask for a personalised plan

Math methods are a small topic, so a student who mostly needs to fix return types and negative rounding can do it in a few one to one sessions. A student who also wants steady practice on loops, Strings, arrays and classes will get more from the two batch classes each week. Fees are shown in your own currency.

Studying outside India?

Math methods practice for ICSE students abroad

ICSE students in the Gulf, Singapore and elsewhere sit the same Computer Applications paper, with the same Math questions. Outside India we teach one to one, at an evening hour that suits the student's time zone.

Where you liveTime differenceUsual class window, local timeFormat
India (IST)
every Indian city
ISTTue 5:30 PM, Wed 8:00 PMMini batch or 1-on-1
United Arab Emirates
Dubai, Sharjah
1 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Indonesia and Thailand
West Java, Bangkok area
1 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1
Singapore
Singapore
2 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1

The slot is agreed after the free demo and can shift during school exams. How overseas classes work is explained on ICSE Computer Applications classes in the Gulf and abroad.

What families say

Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 10 series

More pages for Class 10 board students

Every page in the ICSE Class 10 Computer Applications series, grouped by what you need: classes, each chapter, Section B programs, question practice, notes and revision, and the exam itself.

CBSE Class 10 AI (417): The Mon and Wed 9 PM AI batch CBSE AI 417 syllabus explained CBSE AI important questions Sample paper and mock tests

Questions about Math methods

What students ask about Math library methods in ICSE

Which Math methods are in the ICSE Computer Applications syllabus?

The 2026-27 syllabus lists ten methods of the Math class: pow(x, y), sqrt(x), cbrt(x), ceil(x), floor(x), round(x), abs(a), max(a, b), min(a, b) and random(). They are taught in Class 9 and revised in Class 10, and the 2027 paper can ask about any of them in Section A or use them inside a Section B program.

What is the return type of Math.pow and Math.sqrt?

Both return double, whatever type of argument you pass. So Math.pow(5, 2) prints 25.0 and Math.sqrt(81) prints 9.0. To store the result in an int you must cast it, as in (int) Math.pow(5, 2), and the cast removes any fractional part.

What is the difference between Math.round, Math.ceil and Math.floor?

Math.ceil moves up to the next whole number and Math.floor moves down; both return double, so 6.1 gives 7.0 and 6.0. Math.round goes to the nearest whole number, with halves moving up, and returns a long for a double argument, so 6.5 gives 7 with no decimal point.

What does Math.round(-2.5) return in Java?

It returns -2. Java rounds a half towards positive infinity, and the next whole number up from -2.5 is -2. A value just past the half, such as -2.51, rounds to -3. This is one of the most common Math traps in ICSE output questions.

Why does Math.sqrt of a negative number print NaN?

A negative number has no real square root, so Java returns the special double value NaN, meaning "not a number", instead of stopping with an error. Use Math.cbrt for cube roots of negative numbers, which works, or take Math.abs first if the question allows it.

What is the return type of Math.abs, Math.max and Math.min?

They return the same type as their arguments: int for int arguments and double for double arguments. If one argument is int and the other is double, the int is promoted first, so Math.max(8, 11.0) returns the double 11.0.

How do you generate a random number between 1 and 100 in Java?

Use 1 + (int) (Math.random() * 100). Math.random() gives a double from 0.0 up to but not including 1.0; multiplying by 100 stretches it, the cast removes the fraction to give 0 to 99, and adding 1 shifts it to 1 to 100. Keep the brackets around the multiplication.

Do I need to import anything to use Math methods in Java?

No. The Math class is in the java.lang package, which Java imports into every program automatically. You call its methods through the class name, as in Math.sqrt(x), because they are static; you never create a Math object.

Are trigonometric methods like Math.sin in the ICSE 2027 syllabus?

The 2026-27 syllabus list we checked names only pow, sqrt, cbrt, ceil, floor, round, abs, max, min and random. Some textbooks mention sin, cos, log or exp, but questions should be set from the syllabus list, so learn those ten thoroughly first.

Do you teach Math library methods in live classes?

Yes. In the ICSE mini batch on Tuesday at 5:30 PM IST and Wednesday at 8:00 PM IST, each Tuesday opens with a return-type drill and the methods are then used inside full programs. Personalised one to one classes are available at a time the family picks, in India or abroad.

Start

Try a free live class on Math methods

In the free demo your child names the return type and output of a quick run of Math calls, including the negative halves and the NaN cases, then turns a formula from their own maths book into a Java expression and runs it in BlueJ. You hear plainly afterwards which slips are costing marks.

Want to look around first? See ICSE Computer Applications important questions or the ICSE Class 10 Java classes.

WhatsApp us · +91 91233 66161 · connect@modernagecoders.com

Every class is live video. The form requests a callback and reserves nothing.

We call within a few hours. No card, no enrolment fee.

Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

Book a priority demo

Keep exploring Modern Age Coders

More maths tuition

Learn more

From the blog

Start here