Math.PI is a constant in the Math object of JavaScript that represents the ratio of the circumference of a circle to its diameter. It is approximately equal to 3.14159.
Math.sqrt: This method returns the square root of a number.
Math.random: This function generates a random number between 0 (inclusive) and 1 (exclusive).
Math.floor: This function rounds down a decimal number to the nearest whole number.
AP Computer Science A - Unit 2 Overview: Using Objects
What is the result of the following code? public class Shapes { public double calculateCircleArea(double radius) { return Math.PI * Math.pow(radius, 2); } public double calculateRectangleArea(double length, double width) { return length * width; } public static void main(String[] args) { Shapes shapes = new Shapes(); System.out.println(shapes.calculateCircleArea(5) + shapes.calculateRectangleArea(10, 2)); } }
Study guides for the entire semester
200k practice questions
Glossary of 50k key terms - memorize important vocab
About Fiveable
Blog
Careers
Code of Conduct
Terms of Use
Privacy Policy
CCPA Privacy Policy
Cram Mode
AP Score Calculators
Study Guides
Practice Quizzes
Glossary
Cram Events
Merch Shop
Crisis Text Line
Help Center
About Fiveable
Blog
Careers
Code of Conduct
Terms of Use
Privacy Policy
CCPA Privacy Policy
Cram Mode
AP Score Calculators
Study Guides
Practice Quizzes
Glossary
Cram Events
Merch Shop
Crisis Text Line
Help Center
© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.