Course URL: https://www.codecademy.com/courses/learn-java/lessons/learn-java-methods/exercises/calling-methods
In the example above, we call the
startEngine()
method on themyFastCar
object. This method call occurs inside themain()
method. Running the program results in printingVroom!
to the output terminal.
The last sentence should be corrected to the following since the startEngine()
method prints two statements.
Running the program results in printing
Starting the car!
andVroom!
to the output terminal.
public void startEngine() {
System.out.println("Starting the car!");
System.out.println("Vroom!");
}