1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Object-Oriented Programming in Java

Connected

Exercise

Working with void methods

Classes perform actions using methods, and methods do not always have to return a specific data type. You will implement a method to turn on a car's engine inside the Car class.

Instructions

100 XP
  • Create a void method called turnEngineOn that takes no parameters inside the Car class.
  • Print the message "engine is on" inside the turnEngineOn method.
  • Call the turnEngineOn on the myCar object instance already created for you.