Skip to content
Exercises · Q8

Q.Using the Math class, write Java statements to compute

(i) the square root of 225,
(ii) 2 raised to the power 10, and
(iii) the larger of 47 and 92. State the output of each.
ChseodishaTextbookSubjectiveImportance★★★★★est
57% · 8/14 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The Math class provides static methods, so we call them on the class name Math without creating an object.

(i) Square root of 225.

System.out.println(Math.sqrt(225));   // 15.0

Math.sqrt(x) returns a double, so the result is 15.0, not 15.

(ii) 2 raised to the power 10.

System.out.println(Math.pow(2, 10));  // 1024.0

Math.pow(x, y) computes x to the power y and returns a double, so 1024.0.

(iii) The larger of 47 and 92.

System.out.println(Math.max(47, 92)); // 92

Math.max(a, b) returns the greater of the two. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.