Please enable JavaScript to use CodeHS

AP Computer Science A (Nitro)

Lesson 2.10 Using the Math Class

Description

In this lesson, students will learn about static methods. Static methods are methods that can be called without creating an object. More specifically, students will discover and practice using static methods in the Java Math class. The following Math class methods will be examined in this lesson:

Math.abs(x)
Math.pow(base, exponent)
Math.sqrt(x)
Math.random()
Math.round()
Math.cos()
Math.sin()
Math.PI

This lesson corresponds with AP Computer Science A topic 2.9.


Objective

Students will be able to:

  • Call static methods
  • Evaluate expressions that use the Math class methods