The following script creates a Car object named myCar, calls the fullThrottle method via the myCar object, calls the speed method, and runs the program:
A custom Car class is created by using the class keyword.
The fullThrottle and speed methods in the Car class are created.
The fullThrottle method and the speed method will print out some text, when they are called.
The speed method accepts an int parameter called maxSpeed.
In order to use the Car class and its methods, we need to create an object of the Car class.
Activate the main method, which is the entry point into the program.
By using the new keyword, a Car object with the name myCar is created.
Finally, call the fullThrottle method on the myCar object, and run the program using the name of the object (myCar), followed by a dot (.), followed by the name of the method (fullThrottle) or call the method speed(200) directly.