Random NumbersΒΆ

Games would be boring if the same thing happened each time you played the game. Games often use random numbers to generate different possibilities. You need to know how to use the Math.random() method to generate a random number. There are lots of mathematical methods that you might want to use in your programs like Math.abs (absolute value). These methods are in the Math class and are static (class) methods so that you can call them by just using ClassName.methodName. Class or static methods live in the object that defines the class (an object of a class named Class) and can be accessed directly from the class. You do not need to create an object of the class to use them.

Check your understanding

3-7-1: Which of the following is a correct test for a 40% possibility?